結果
問題 | No.401 数字の渦巻き |
ユーザー |
![]() |
提出日時 | 2021-08-01 22:33:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 466 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 59,136 KB |
最終ジャッジ日時 | 2024-09-16 13:03:25 |
合計ジャッジ時間 | 2,541 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
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)) + treturn retp = 0x,y = 0,0for 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 += 1elif d[xx][yy] != 0:p += 1x += lis[p%4][0]y += lis[p%4][1]for i in range(n):print(*d[i])