# Unlocker Codevita 9 Solution

## Unlocker Codevita 9 Solution 2020

A storage is included at least one layers. Each layer can be turned uniquely one way. Odd numbered layers turn in hostile to clockwise heading (left to right), and even numbered layers pivot clockwise way (option to left).

You are given a storage, as a lattice. The network will be rectangular fit as a fiddle. The external most layer of this network is layer1. In setting of the outline beneath, the numbers painted in red are layer1 and the internal numbers comprise layer2. Greater frameworks will have more layers.

One revolution characterized as a given number moving in the neighboring spot for example one spot left for clockwise turn and one spot directly for against clockwise pivot.

Number of revolutions for each layer needed to open the storage will be given as info. Print the last opened network as yield.

com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@134a2ab9:image1.png

com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@134a2ab9:image2.png

Requirements

• 1 < M, N <= 300
• 0 <= Numbers in grid < 100
• 1 <= Number of pivots <= 10^9
• M%2=0 && N%2=0

Information

First line contains two space isolated whole number M and N which indicates the quantity of lines and number of sections, separately

Next M lines contain N space isolated whole numbers portraying the bolted network

Keep going line contains L space isolated whole numbers, where L is the quantity of layers. Each number on this line indicates the quantity of turns for each layer from 1 to L

Yield

Print opened grid

Time Limit

Models

Model 1

Information

1 2

3 4

Yield

4 3

2 1

Clarification:

There is just one layer. Thus, we need to pivot it in against clockwise heading with 2 turns.

com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@134a2ab9:image3.png

Model 2

Info

1 2 3 4

2 3 4 5

2 4 5 6

2 3 4 5

Yield

3 4 5 6

2 5 4 5

1 4 3 4

2 3

Clarification:

Here we need to turn layer1 in against clockwise heading with 2 revolutions, and layer2 clockwise with 2 pivots.