結果
問題 | No.2212 One XOR Matrix |
ユーザー | Shirotsume |
提出日時 | 2022-11-25 22:55:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 440 ms / 2,000 ms |
コード長 | 1,751 bytes |
コンパイル時間 | 589 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 94,704 KB |
最終ジャッジ日時 | 2024-10-03 03:51:01 |
合計ジャッジ時間 | 3,356 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
54,144 KB |
testcase_01 | AC | 41 ms
53,760 KB |
testcase_02 | AC | 40 ms
54,272 KB |
testcase_03 | AC | 42 ms
54,656 KB |
testcase_04 | AC | 46 ms
60,800 KB |
testcase_05 | AC | 67 ms
74,236 KB |
testcase_06 | AC | 77 ms
77,268 KB |
testcase_07 | AC | 102 ms
77,696 KB |
testcase_08 | AC | 170 ms
79,872 KB |
testcase_09 | AC | 440 ms
94,704 KB |
ソースコード
import sys from collections import deque, Counter sys.setrecursionlimit(5 * 10 ** 5) from pypyjit import set_param set_param('max_unroll_recursion=-1') input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n = ii() def solve(n): if n == 1: return [-1] if n == 2: return [[7, 14, 0, 8],[4, 12, 2, 11],[15, 9, 6, 1], [13, 10, 5, 3]] else: X = solve(n - 1) Y = [[0] * (1 << (n - 1)) for _ in range(1 << (n - 1))] for i in range(1<<(n - 1)): for j in range(1 << (n - 1)): Y[i][j] = i * (1<<(n - 1)) + j ans = [[0] * (1<<n) for _ in range(1<<n)] for i in range(1 << (n - 1)): for j in range(1<<(n - 1)): ans[i][j] = X[i][j] for i in range(1 << (n - 1), 1<<n): for j in range(1<<(n - 1)): ans[i][j] = Y[i - (1<<(n-1))][j] + 2 ** (2 * n - 2) for i in range(1 << (n - 1)): for j in range(1 << (n - 1), 1<<n): ans[i][j] = Y[i][j - (1<<(n-1))] + 2 ** (2 * n - 1) for i in range(1 << (n - 1), 1<<n): for j in range(1 << (n - 1), 1<<n): ans[i][j] = X[i - (1<<(n-1))][j - (1<<(n-1))] + 2 ** (2 * n - 1) + 2 ** (2 * n - 2) return ans ans = solve(n) if n == 1: print(-1) else: for i in range(1<<n): xor = 0 for j in range(1<<n): xor ^= ans[i][j] assert xor == 1 for j in range(1<<n): xor = 0 for i in range(1<<n): xor ^= ans[i][j] assert xor == 1 for v in ans: print(*v)