結果

問題 No.401 数字の渦巻き
ユーザー aqua_tenhouaqua_tenhou
提出日時 2021-08-01 22:33:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 75,508 KB
最終ジャッジ日時 2023-10-14 19:03:56
合計ジャッジ時間 3,843 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,104 KB
testcase_01 AC 70 ms
71,600 KB
testcase_02 AC 71 ms
71,380 KB
testcase_03 AC 71 ms
71,536 KB
testcase_04 AC 70 ms
71,308 KB
testcase_05 AC 71 ms
71,144 KB
testcase_06 AC 70 ms
71,268 KB
testcase_07 AC 70 ms
71,268 KB
testcase_08 AC 71 ms
71,144 KB
testcase_09 AC 71 ms
71,372 KB
testcase_10 AC 71 ms
71,404 KB
testcase_11 AC 72 ms
71,120 KB
testcase_12 AC 70 ms
71,320 KB
testcase_13 AC 71 ms
71,400 KB
testcase_14 AC 71 ms
71,144 KB
testcase_15 AC 70 ms
71,412 KB
testcase_16 AC 70 ms
71,508 KB
testcase_17 AC 71 ms
71,404 KB
testcase_18 AC 72 ms
71,420 KB
testcase_19 AC 72 ms
71,256 KB
testcase_20 AC 72 ms
71,288 KB
testcase_21 AC 72 ms
71,292 KB
testcase_22 AC 71 ms
71,268 KB
testcase_23 AC 74 ms
71,440 KB
testcase_24 AC 73 ms
71,536 KB
testcase_25 AC 75 ms
71,324 KB
testcase_26 AC 74 ms
71,516 KB
testcase_27 AC 75 ms
71,440 KB
testcase_28 AC 77 ms
75,508 KB
testcase_29 AC 76 ms
75,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
lis = [[0,1],[1,0],[0,-1],[-1,0]]

d = [[0 for i in range(n)] for j in range(n)]

def f(x):
    t = str(x)
    ret = "0"*(3-len(t)) + t
    return ret


p = 0
x,y = 0,0
for i in range(n**2):
    d[x][y] = f(i+1)

    xx = x + lis[p%4][0]
    yy = y + lis[p%4][1]
    if xx == -1 or xx == n or yy == -1 or yy == n:
        p += 1
    elif d[xx][yy] != 0:
        p += 1
    x += lis[p%4][0]
    y += lis[p%4][1]


for i in range(n):
    print(*d[i])
0