結果

問題 No.401 数字の渦巻き
ユーザー maspymaspy
提出日時 2020-01-20 16:57:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 29,708 KB
最終ジャッジ日時 2023-09-15 21:12:53
合計ジャッジ時間 5,830 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
29,508 KB
testcase_01 AC 143 ms
29,612 KB
testcase_02 AC 140 ms
29,552 KB
testcase_03 AC 142 ms
29,560 KB
testcase_04 AC 139 ms
29,560 KB
testcase_05 AC 149 ms
29,648 KB
testcase_06 AC 136 ms
29,528 KB
testcase_07 AC 137 ms
29,688 KB
testcase_08 AC 139 ms
29,608 KB
testcase_09 AC 137 ms
29,472 KB
testcase_10 AC 136 ms
29,464 KB
testcase_11 AC 133 ms
29,524 KB
testcase_12 AC 139 ms
29,700 KB
testcase_13 AC 137 ms
29,612 KB
testcase_14 AC 140 ms
29,496 KB
testcase_15 AC 138 ms
29,684 KB
testcase_16 AC 144 ms
29,624 KB
testcase_17 AC 145 ms
29,680 KB
testcase_18 AC 139 ms
29,572 KB
testcase_19 AC 156 ms
29,472 KB
testcase_20 AC 142 ms
29,608 KB
testcase_21 AC 142 ms
29,496 KB
testcase_22 AC 139 ms
29,708 KB
testcase_23 AC 143 ms
29,556 KB
testcase_24 AC 141 ms
29,544 KB
testcase_25 AC 149 ms
29,540 KB
testcase_26 AC 146 ms
29,504 KB
testcase_27 AC 142 ms
29,692 KB
testcase_28 AC 143 ms
29,592 KB
testcase_29 AC 144 ms
29,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(read())

A = np.zeros((N+2,N+2),np.int32)

A[0] = -1
A[-1] = -1
A[:,0] = -1
A[:,-1] = -1
x,y = 1,1
dx,dy = 0,1
A[1,1] = 1
for _ in range(N*N-1):
    if A[x+dx,y+dy] != 0:
        dx,dy = dy,-dx
    A[x+dx,y+dy] = A[x,y] + 1
    x += dx
    y += dy

A = A[1:-1,1:-1]

for row in A:
    print(' '.join('{:03}'.format(x) for x in row))
0