Grid with equal xor
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given an integer n which is a multiple of 4. Find an n x n grid for which the bitwise xor of every row and every column is the same. Each number from 0 to n^2
- 1 must appear in the grid exactly once.
Input
One integer n (1 ≤ n ≤ 1000) which is a multiple of 4.
Output
Print an n x n grid with numbers from 0 to n^2
- 1 for which the bitwise xor of every row and column is the same. If there are multiple solutions, print any.
Examples
Input #1
Answer #1
Submissions 699
Acceptance rate 58%