結果
問題 | No.401 数字の渦巻き |
ユーザー |
![]() |
提出日時 | 2023-10-20 14:06:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 489 bytes |
コンパイル時間 | 311 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 59,392 KB |
最終ジャッジ日時 | 2024-09-20 09:37:30 |
合計ジャッジ時間 | 2,411 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
n = int(input())A = [[0 for i in range(n)] for j in range(n)]A[0][0] = 1f = Trueh = ((0, 1), (-1, 0), (0, -1), (1, 0))c = 0i, j = 0, 0while A[i][j] < n**2:while (0 <= (ii := i + h[c % 4][0]) < nand 0 <= (jj := j + h[c % 4][1]) < nand A[ii][jj] == 0):A[i + h[c % 4][0]][j + h[c % 4][1]] = A[i][j] + 1i, j = i + h[c % 4][0], j + h[c % 4][1]c += 1for a in A:print(*map(lambda x: "0" * (3 - len(str(x))) + str(x), a))