結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
piconic_X
|
| 提出日時 | 2016-08-11 19:22:30 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 1,196 bytes |
| コンパイル時間 | 206 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-11-07 11:01:34 |
| 合計ジャッジ時間 | 1,998 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
def make_arr(N):
arr = [[1 for i in range(N)] for i in range(N)]
return arr
def next_pos(start, dist, arr, N): # dist = 1(right), -1(left)
k = start[0]
l = start[1]
pos = k,l
while arr[k][l+dist] == 1:
if (k,l+dist) == (0,0):
break
num = arr[k][l]
l += dist
arr[k][l] = num + 1
if l == N-1 or l == 0:
break
pos = l,k
return pos
def splitter(col):
l = len(col)
s = ''
for i in range(l):
s += '{0:0>3} '.format(col[i])
return s
def main():
N = int(input())
if N == 1:
print('001')
else:
arr = make_arr(N)
i = 0
pos = 0,0
while i >= 0:
phase = i % 4
pre_pos = pos
if phase < 2:
pos = next_pos(pre_pos, 1, arr, N)
else:
pos = next_pos(pre_pos, -1, arr, N)
arr = list(map(list, zip(*arr)))
if (pos[1], pos[0]) == pre_pos:
col = len(arr)
for i in range(col):
print( splitter(arr[i]) )
break
else:
i += 1
return 0
main()
piconic_X