結果

問題 No.401 数字の渦巻き
ユーザー 👑 H20H20
提出日時 2020-11-20 09:09:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 75,192 KB
最終ジャッジ日時 2023-09-30 18:18:35
合計ジャッジ時間 4,862 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
71,116 KB
testcase_01 AC 85 ms
71,020 KB
testcase_02 AC 83 ms
71,004 KB
testcase_03 AC 80 ms
70,960 KB
testcase_04 AC 72 ms
70,976 KB
testcase_05 AC 72 ms
71,012 KB
testcase_06 AC 73 ms
70,800 KB
testcase_07 AC 74 ms
71,240 KB
testcase_08 AC 73 ms
71,164 KB
testcase_09 AC 74 ms
71,180 KB
testcase_10 AC 73 ms
70,948 KB
testcase_11 AC 73 ms
71,156 KB
testcase_12 AC 72 ms
70,992 KB
testcase_13 AC 72 ms
71,156 KB
testcase_14 AC 71 ms
71,072 KB
testcase_15 AC 73 ms
71,068 KB
testcase_16 AC 73 ms
71,156 KB
testcase_17 AC 76 ms
71,064 KB
testcase_18 AC 79 ms
71,100 KB
testcase_19 AC 80 ms
71,064 KB
testcase_20 AC 76 ms
70,960 KB
testcase_21 AC 73 ms
71,116 KB
testcase_22 AC 76 ms
70,972 KB
testcase_23 AC 76 ms
71,192 KB
testcase_24 AC 75 ms
71,012 KB
testcase_25 AC 77 ms
71,188 KB
testcase_26 AC 78 ms
71,060 KB
testcase_27 AC 80 ms
70,800 KB
testcase_28 AC 90 ms
75,192 KB
testcase_29 AC 79 ms
74,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
X = [1,0,-1,0]
Y = [0,1,0,-1]
MAP = [['0'.zfill(3)] * N for i in range(N)]
cnt = 1
x = 0
y = 0
di = 0
while cnt <= N**2:
    MAP[y][x]=str(cnt).zfill(3)
    if x + X[di] <0 or x+X[di]>=N or y+Y[di]<0 or y+Y[di]>=N or MAP[y+Y[di]][x+X[di]]!='000':
        di = (di +1)%4
    x += X[di]
    y += Y[di]
    cnt += 1

for i in range(N):
    print(*MAP[i])
0