結果
| 問題 |
No.401 数字の渦巻き
|
| ユーザー |
|
| 提出日時 | 2021-02-23 21:53:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 570 bytes |
| コンパイル時間 | 376 ms |
| コンパイル使用メモリ | 82,688 KB |
| 実行使用メモリ | 52,992 KB |
| 最終ジャッジ日時 | 2024-09-22 16:07:26 |
| 合計ジャッジ時間 | 2,731 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 21 |
ソースコード
N = int(input())
dr = [0, 1, 0, -1]
dc = [1, 0, -1, 0]
r = 0
c = 0
d = 0
i = 1
grid = [[-1] * N for i in range(N)]
while i <= N * N:
grid[r][c] = i
i += 1
nr = r + dr[d]
nc = c + dc[d]
if 0 <= nr < N and 0 <= nc < N and grid[nr][nc] == -1:
r = nr
c = nc
else:
d = (d + 1) % 4
r = r + dr[d]
c = c + dc[d]
def pr(x):
if x < 10:
print("00" + str(x), end = " ")
elif x < 100:
print("0" + str(x), end = " ")
for i in range(N):
for j in range(N):
pr(grid[i][j])
print("")