結果
問題 | 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 = 0j = 0k = 0x = 1while not A[i][j]:A[i][j] = str(x).zfill(3)x += 1if k == 0:if j < N - 1 and not A[i][j + 1]:j += 1else:i += 1k = 1elif k == 1:if i < N - 1 and not A[i + 1][j]:i += 1else:j -= 1k = 2elif k == 2:if j > 0 and not A[i][j - 1]:j -= 1else:i -= 1k = 3else:if i > 0 and not A[i - 1][j]:i -= 1else:j += 1k = 0for a in A:print(*a)