結果
問題 | No.401 数字の渦巻き |
ユーザー |
![]() |
提出日時 | 2019-05-20 04:48:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 659 bytes |
コンパイル時間 | 75 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-17 06:38:10 |
合計ジャッジ時間 | 1,894 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
def n_dire(): dire = 0 while True: yield dire dire = (dire + 1) % 4 N = int(input()) nums = [[0 for x in range(N)] for y in range(N)] nd = n_dire() turn = False n = N ** 2 c = 1 x = -1 y = 0 step = N while c <= n: dire = next(nd) for i in range(step): if dire % 2: if dire == 1: y+=1 elif dire == 3: y-=1 else: if dire == 0: x+=1 elif dire == 2: x-=1 nums[y][x] = c c+=1 turn^=True if turn: step-=1 for i in nums: print(" ".join(map(lambda x:format(x,"03d"),i)))