| Lincatoria Problems |
|---|
| Finished |
A Pebble Automaton is a grid of cells. Each cell can contain some number of stones. In every iteration, each cell can move some number of stones up, right, down and left. Each cell only knows two things, based on which it will make its decision:
It knows nothing about other cells, previous or current iteration. It just moves the stones based on how many stones it has.

Your task is to define these functions for every cell, such that in the end you calculate something!
For each task, the grid is initially empty. Then, $$$A$$$ stones are placed in the top left corner and $$$B$$$ stones are placed in the top right corner. After that, the iterations start. Each iteration, every cell moves its stones simultaneously. If during some iteration no stones were moved, the Pebble Automaton stops and the final grid state is considered the output.
You need to solve $$$5$$$ separate tasks:
For each task, remaining cells in the grid can have any number of stones. You will get $$$50\%$$$ of points for a task if you only solve it for odd grid size $$$N$$$.
Constraints:
First line contains two numbers – $$$S (1 \leq S \leq 5)$$$ and $$$N (5 \leq N \leq 10)$$$. $$$S$$$ is the number of the task, $$$N$$$ is the size of the grid. The grid is always square.
The grader will ask you some number of queries. Each query is $$$3$$$ numbers – $$$x$$$, $$$y$$$ ($$$1 \leq x, y \leq N$$$) and $$$count$$$ ($$$0 \leq count \leq 200$$$). Each query asks about the cell in row $$$x$$$ and column $$$y$$$ with $$$count$$$ stones.
The output for each query is $$$4$$$ numbers separated by spaces – $$$u$$$, $$$r$$$, $$$d$$$ and $$$l$$$. This is the number of stones moved up, right, down and left respectively. The remaining stones will stay in this cell. Each query must be answered on a separate line with flushed output.
To read queries, use while(cin >> x >> y >> count) in C++ or for line in sys.stdin in Python.
The queries will be called in any order so you don't have any information about the other cells or the previous iteration.
| Name |
|---|


