atcoder#AGC030C. [AGC030C] Coloring Torus
[AGC030C] Coloring Torus
Score : points
Problem Statement
For an grid, let denote the square at the -th row from the top and the -th column from the left. A good coloring of this grid using colors is a coloring that satisfies the following:
- Each square is painted in one of the colors.
- Each of the colors is used for some squares.
- Let us number the colors . For any colors and (), every square in Color has the same number of adjacent squares in Color . Here, the squares adjacent to square are $((r-1)\; mod\; n, c), ((r+1)\; mod\; n, c), (r, (c-1)\; mod\; n)$ and (if the same square appears multiple times among these four, the square is counted that number of times).
Given , choose n between 1 and 500 (inclusive) freely and construct a good coloring of an grid using colors. It can be proved that this is always possible under the constraints of this problem,
Constraints
Input
Input is given from Standard Input in the following format:
Output
Output should be in the following format:
should represent the size of the grid, and must hold. should be an integer such that and represent the color for the square .
2
3
1 1 1
1 1 1
2 2 2
- Every square in Color has three adjacent squares in Color and one adjacent square in Color .
- Every square in Color has two adjacent squares in Color and two adjacent squares in Color .
Output such as the following will be judged incorrect:
2
1 2
2 2
3
1 1 1
1 1 1
1 1 1
9
3
1 2 3
4 5 6
7 8 9