結果
問題 |
No.401 数字の渦巻き
|
ユーザー |
![]() |
提出日時 | 2020-09-01 00:14:54 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 495 bytes |
コンパイル時間 | 197 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-17 02:59:28 |
合計ジャッジ時間 | 2,047 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
N = int(input().strip()) a = [[0 for _ in range(N)] for _ in range(N)] lst = [(1, 0), (0, 1), (-1, 0), (0, -1)] cnt = 1 idx = 0 #b = lst[0] x, y = 0, 0 x_tmp, y_tmp = 0, 0 while True: if cnt > N**2: break if a[y_tmp % N][x_tmp % N] > 0: idx += 1 else: a[y_tmp][x_tmp] = cnt cnt += 1 x, y = x_tmp, y_tmp x_tmp, y_tmp = x + lst[idx % len(lst)][0], y + lst[idx % len(lst)][1] for y in range(N): print(' '.join(['{:03d}'.format(a[y][i]) for i in range(N)]))