結果
問題 | No.401 数字の渦巻き |
ユーザー |
![]() |
提出日時 | 2023-03-21 11:01:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 688 bytes |
コンパイル時間 | 349 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 58,880 KB |
最終ジャッジ日時 | 2024-09-18 14:19:11 |
合計ジャッジ時間 | 2,558 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
# 愚直にぐるぐるやるか、計算でやるか# N<30なので愚直にやってみるかN = int(input())grid = [[-1]*N for i in range(N)]move = [[0, 1], [1, 0], [0, -1], [-1, 0]]i = 0j = 0count = 1001grid[i][j] = str(count)[1:]count += 1direction = 0while True:moving = Falsewhile 0 <= i+move[direction][0] < N and 0 <= j+move[direction][1] < N and grid[i+move[direction][0]][j+move[direction][1]] == -1:i += move[direction][0]j += move[direction][1]grid[i][j] = str(count)[1:]count += 1moving = Truedirection = (direction+1)%4if moving == False:break#print(grid)for g in grid:print(*g)