結果

問題 No.401 数字の渦巻き
ユーザー ABKZABKZ
提出日時 2023-07-05 23:47:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 86,664 KB
実行使用メモリ 71,376 KB
最終ジャッジ日時 2023-09-27 00:35:15
合計ジャッジ時間 4,609 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,940 KB
testcase_01 AC 69 ms
71,324 KB
testcase_02 AC 71 ms
71,076 KB
testcase_03 AC 71 ms
71,080 KB
testcase_04 AC 70 ms
71,320 KB
testcase_05 AC 72 ms
71,316 KB
testcase_06 AC 72 ms
71,108 KB
testcase_07 AC 70 ms
70,776 KB
testcase_08 AC 70 ms
71,372 KB
testcase_09 AC 70 ms
70,952 KB
testcase_10 AC 70 ms
71,308 KB
testcase_11 AC 72 ms
71,076 KB
testcase_12 AC 71 ms
71,116 KB
testcase_13 AC 73 ms
71,120 KB
testcase_14 AC 70 ms
71,360 KB
testcase_15 AC 73 ms
70,960 KB
testcase_16 AC 73 ms
71,212 KB
testcase_17 AC 71 ms
70,800 KB
testcase_18 AC 71 ms
71,108 KB
testcase_19 AC 71 ms
71,268 KB
testcase_20 AC 71 ms
71,092 KB
testcase_21 AC 72 ms
71,356 KB
testcase_22 AC 72 ms
71,376 KB
testcase_23 AC 72 ms
71,320 KB
testcase_24 AC 70 ms
71,304 KB
testcase_25 AC 73 ms
71,048 KB
testcase_26 AC 72 ms
71,320 KB
testcase_27 AC 73 ms
71,304 KB
testcase_28 AC 72 ms
70,960 KB
testcase_29 AC 71 ms
71,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

a = [[0 for _ in range(N)] for _ in range(N) ]

b = [[x1, x2] for x1, x2 in zip(range(N), reversed(range(N)))]

yyy = sum(b, [])[:N]

xxx = sum(reversed(b), [])[:N]

xy = []
for i in range(N):
    xy.append([xxx[i], yyy[i]])
    if i == N-1:
        break
    xy.append([xxx[i], yyy[i+1]])



x = 0
y = 0
v = 1
for x_, y_ in xy:
    if x == x_:
        yy = list(range(y, y_+1)) if y <= y_ else reversed(list(range(y_, y+1)))
        for y__ in yy:
            if a[y__][x] == 0:
                a[y__][x] = v
                y = y__
                v = v+1
    elif y == y_:
        xx = list(range(x, x_+1)) if x <= x_ else reversed(list(range(x_, x+1)))
        for x__ in xx:
            if a[y][x__] == 0:
                a[y][x__] = v
                x = x__
                v = v+1

for r in a:
    z = [str(n).zfill(3) for n in r]
    print(' '.join(z))
0