結果

問題 No.2212 One XOR Matrix
ユーザー minimumminimum
提出日時 2023-02-10 22:56:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 1,072 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 87,312 KB
実行使用メモリ 86,568 KB
最終ジャッジ日時 2023-09-22 00:04:24
合計ジャッジ時間 3,885 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,448 KB
testcase_01 AC 73 ms
71,260 KB
testcase_02 AC 75 ms
71,312 KB
testcase_03 AC 76 ms
71,604 KB
testcase_04 AC 81 ms
75,628 KB
testcase_05 AC 96 ms
76,928 KB
testcase_06 AC 103 ms
77,588 KB
testcase_07 AC 120 ms
78,192 KB
testcase_08 AC 145 ms
80,036 KB
testcase_09 AC 247 ms
86,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
if N == 1:
    exit(print(-1))
if N == 2:
    print(7, 14, 0, 8)
    print(4, 12, 2, 11)
    print(15, 9, 6, 1)
    print(13, 10, 5, 3)
    exit()

A = [[0] * (1 << N) for _ in range(1 << N)]
for i in range(1 << (2 * N - 2)):
    r = i // (1 << (N - 1))
    c = i % (1 << (N - 1))
    A[r][c] = i
    A[(1 << N) - 1 - c][r] = i
    A[c][(1 << N) - 1 - r] = i
    A[r + (1 << (N - 1))][c + (1 << (N - 1))] = i

for i in range(1 << N):
    for j in range(1 << N):
        A[i][j] <<= 1
        if i < (1 << (N - 1)):
            A[i][j] += 1
        A[i][j] <<= 1

for i in range(1 << N):
    for j in range(1 << N):
        if i < (1 << (N - 1)) and j < (1 << (N - 1)):
            if i == 0:
                A[i][j] += 1
        elif i < (1 << (N - 1)) and j >= (1 << (N - 1)):
            if j != ((1 << N) - 1):
                A[i][j] += 1
        elif i >= (1 << (N - 1)) and j < (1 << (N - 1)):
            if j != 0:
                A[i][j] += 1
        else:
            if i == 1 << (N - 1):
                A[i][j] += 1

for a in A:
    print(*a)
0