結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-06 16:44:20 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 415 bytes |
| コンパイル時間 | 210 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-12-29 08:35:46 |
| 合計ジャッジ時間 | 2,476 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
N = int(input())
grid = [[0] * N for _ in range(N)]
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
x, y = 0, 0
d = 0
for i in range(1, N * N + 1):
grid[x][y] = i
nx = x + dx[d]
ny = y + dy[d]
if nx < 0 or nx >= N or ny < 0 or ny >= N or grid[nx][ny] != 0:
d = (d + 1) % 4
nx = x + dx[d]
ny = y + dy[d]
x, y = nx, ny
for row in grid:
print(" ".join(f"{x:03}" for x in row))