結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-31 20:11:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 786 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 58,624 KB |
| 最終ジャッジ日時 | 2024-11-17 02:20:06 |
| 合計ジャッジ時間 | 2,433 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
N = int(input())
if N == 1:
print('001')
exit()
A = [['' for i in range(N)] for j in range(N)]
i = 0
j = 0
k = 0
x = 1
while not A[i][j]:
A[i][j] = str(x).zfill(3)
x += 1
if k == 0:
if j < N - 1 and not A[i][j + 1]:
j += 1
else:
i += 1
k = 1
elif k == 1:
if i < N - 1 and not A[i + 1][j]:
i += 1
else:
j -= 1
k = 2
elif k == 2:
if j > 0 and not A[i][j - 1]:
j -= 1
else:
i -= 1
k = 3
else:
if i > 0 and not A[i - 1][j]:
i -= 1
else:
j += 1
k = 0
for a in A:
print(*a)