結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
tookunn_1213
|
| 提出日時 | 2016-07-23 00:05:56 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 510 bytes |
| コンパイル時間 | 483 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-11-06 09:56:04 |
| 合計ジャッジ時間 | 2,103 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 29 RE * 1 |
ソースコード
N = int(input())
s = [['' for j in range(N)]for i in range(N)]
used = [[False for j in range(N)] for i in range(N)]
dy = [0,1,0,-1]
dx = [1,0,-1,0]
q = [[0,0]]
it,k = 0,1
while len(q) > 0:
p = q.pop(0)
used[p[0]][p[1]] = True
s[p[0]][p[1]] = '%03d' % k
k += 1
ny = p[0] + dy[it]
nx = p[1] + dx[it]
if ny < 0 or ny >= N or nx < 0 or nx >= N or used[ny][nx]:
it = (it + 1) % 4
ny = p[0] + dy[it]
nx = p[1] + dx[it]
if not used[ny][nx]:
q.append([ny,nx])
for i in range(N):
print(' '.join(s[i]))
tookunn_1213