結果

問題 No.1587 012 Matrix
ユーザー 👑 rin204rin204
提出日時 2022-01-26 17:07:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 1,000 ms
コード長 477 bytes
コンパイル時間 1,876 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 81,348 KB
最終ジャッジ日時 2023-08-24 22:34:16
合計ジャッジ時間 3,934 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,268 KB
testcase_01 AC 70 ms
71,144 KB
testcase_02 AC 71 ms
71,092 KB
testcase_03 AC 70 ms
71,092 KB
testcase_04 AC 71 ms
71,212 KB
testcase_05 AC 70 ms
71,168 KB
testcase_06 AC 71 ms
71,432 KB
testcase_07 AC 72 ms
71,088 KB
testcase_08 AC 81 ms
76,524 KB
testcase_09 AC 84 ms
76,588 KB
testcase_10 AC 85 ms
76,556 KB
testcase_11 AC 87 ms
76,688 KB
testcase_12 AC 89 ms
77,004 KB
testcase_13 AC 97 ms
78,656 KB
testcase_14 AC 102 ms
78,780 KB
testcase_15 AC 107 ms
80,184 KB
testcase_16 AC 112 ms
80,736 KB
testcase_17 AC 114 ms
80,688 KB
testcase_18 AC 115 ms
81,144 KB
testcase_19 AC 118 ms
81,256 KB
testcase_20 AC 118 ms
81,256 KB
testcase_21 AC 119 ms
81,348 KB
testcase_22 AC 71 ms
71,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

ans = [[0] * n for _ in range(n)]
for i in range(n):
    if i % 2 == 0:
        ans[i][i] = 1
    else:
        ans[i][i] = 2
    for j in range(i):
        ans[i][j] = 2
        
for row in ans:
    print(*row, sep="")
    
se = set()
for i in range(n):
    tot = 0
    for j in range(n):
        tot += ans[i][j]
    se.add(tot)
    
for j in range(n):
    tot = 0
    for i in range(n):
        tot += ans[i][j]
    se.add(tot)
    
assert len(se) == 2 * n
0