結果

問題 No.3092 Tired Queen
ユーザー titia
提出日時 2025-05-06 03:30:47
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,230 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 46,464 KB
最終ジャッジ日時 2025-05-06 03:31:03
合計ジャッジ時間 16,358 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
    
ANS=[[-1]*N for i in range(N)]

x=0
y=0
c=1

for i in range(N*N):
    ANS[x][y]=c
    c+=1

    if x==y and x!=0:
        if x%2==1:
            x+=1
            y+=1
        else:
            x-=1
        continue

    if ANS[y][x]==-1:
        x,y=y,x
        continue

    if x==0:
        y+=1
        continue
        
    MAX=max(x,y)

    if MAX%2==0:
        if x==MAX:
            y-=1
        else:
            x-=1
    else:
        if x==MAX:
            y+=1
        else:
            x+=1

for ans in ANS:
    print(*ans)
        
        
0