結果
| 問題 |
No.401 数字の渦巻き
|
| ユーザー |
FromBooska
|
| 提出日時 | 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 = 0
j = 0
count = 1001
grid[i][j] = str(count)[1:]
count += 1
direction = 0
while True:
moving = False
while 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 += 1
moving = True
direction = (direction+1)%4
if moving == False:
break
#print(grid)
for g in grid:
print(*g)
FromBooska