結果

問題 No.401 数字の渦巻き
ユーザー MarioMario
提出日時 2019-06-24 22:25:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 8,340 KB
最終ジャッジ日時 2023-09-04 06:14:13
合計ジャッジ時間 3,406 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,192 KB
testcase_01 AC 17 ms
8,292 KB
testcase_02 AC 17 ms
8,292 KB
testcase_03 AC 17 ms
8,124 KB
testcase_04 AC 16 ms
8,128 KB
testcase_05 AC 17 ms
8,172 KB
testcase_06 AC 17 ms
8,132 KB
testcase_07 AC 17 ms
8,180 KB
testcase_08 AC 17 ms
8,196 KB
testcase_09 AC 17 ms
8,200 KB
testcase_10 AC 17 ms
8,140 KB
testcase_11 AC 17 ms
8,260 KB
testcase_12 AC 17 ms
8,132 KB
testcase_13 AC 17 ms
8,292 KB
testcase_14 AC 17 ms
8,196 KB
testcase_15 AC 17 ms
8,152 KB
testcase_16 AC 17 ms
8,192 KB
testcase_17 AC 17 ms
8,268 KB
testcase_18 AC 17 ms
8,276 KB
testcase_19 AC 17 ms
8,224 KB
testcase_20 AC 17 ms
8,204 KB
testcase_21 AC 17 ms
8,284 KB
testcase_22 AC 17 ms
8,340 KB
testcase_23 AC 17 ms
8,340 KB
testcase_24 AC 17 ms
8,252 KB
testcase_25 AC 17 ms
8,184 KB
testcase_26 AC 17 ms
8,240 KB
testcase_27 AC 17 ms
8,204 KB
testcase_28 AC 17 ms
8,268 KB
testcase_29 AC 17 ms
8,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import cycle

n = int(input())
m = list(range(1, n)[::-1])
l = [i for i in m for _ in [0] * 2]
p = [n-1] + l

m = [(i, j, k) for i, j, k in zip(cycle([0, 1, 0, -1]), cycle([1, 0, -1, 0]), p)]
q = [[str(1).zfill(3)] * n for _ in [0]*n]
cnt = 1
tmpi = 0
tmpj = 0
for i, j, k in m:
    for _ in [0]*(k):
        cnt += 1
        tmpi += i
        tmpj += j
        q[tmpi][tmpj] = str(cnt).zfill(3)

[print(*i) for i in q]

# 1, 1, 1 -> 3
# 001 002
# 004 003

# 2, 2, 2, 1, 1 -> 5
# 001 002 003
# 008 009 004
# 007 006 005

# 3, 3, 3, 2, 2, 1, 1 -> 7
# 001 002 003 004
# 012 013 014 005
# 011 016 015 006
# 010 009 008 007

# 4, 4, 4, 3, 3, 2, 2, 1, 1, -> 9
# 001 002 003 004 005
# 016 017 018 019 006
# 015 024 025 020 007
# 014 023 022 021 008
# 013 012 011 010 009
0