結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
yn
|
| 提出日時 | 2016-07-22 23:29:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 42 ms / 2,000 ms |
| コード長 | 820 bytes |
| コンパイル時間 | 163 ms |
| コンパイル使用メモリ | 82,204 KB |
| 実行使用メモリ | 55,008 KB |
| 最終ジャッジ日時 | 2024-11-06 09:26:44 |
| 合計ジャッジ時間 | 2,320 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
n = int(input())
ans = [["" for i in range(n)] for j in range(n)]
i = 0
j = 0
imax = n
imin = 0
jmax = n
jmin = 1
cnt = 0
cnt2 = 0
while True:
# 右
while i < imax:
cnt += 1
ans[j][i] = '{0:03d}'.format(cnt)
i += 1
if cnt >= n * n:
break
i -= 1
imax -= 1
j += 1
# 下
while j < jmax:
cnt += 1
ans[j][i] = '{0:03d}'.format(cnt)
j += 1
j -= 1
jmax -= 1
i -= 1
# 左
while i >= imin:
cnt += 1
ans[j][i] = '{0:03d}'.format(cnt)
i -= 1
i += 1
imin += 1
j -= 1
if cnt >= n * n:
break
# 上
while j >= jmin:
cnt += 1
ans[j][i] = '{0:03d}'.format(cnt)
j -= 1
j += 1
jmin += 1
i += 1
for i in range(n):
print(" ".join(ans[i][:]))
yn