結果
問題 | No.3092 Tired Queen |
ユーザー |
![]() |
提出日時 | 2025-04-06 16:18:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 181 ms / 2,000 ms |
コード長 | 1,622 bytes |
コンパイル時間 | 497 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 84,616 KB |
最終ジャッジ日時 | 2025-04-06 16:18:42 |
合計ジャッジ時間 | 6,743 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 |
ソースコード
N=int(input()) result=[[0]*N for i in range(N)] c=0 x=0 y=0 t=0 count=0 while True: if c==N**2: break if t==0: if x==y or x==N-1-y: c+=1 result[x][y]=c if c==N**2: break c+=1 a,b=N-1-x,N-1-y result[a][b]=c c+=1 a,b=x,N-1-y result[a][b]=c c+=1 a,b=N-1-x,y result[a][b]=c t=1 x,y=N-1-x,y if count%2==0: y+=1 else: y-=1 else: c+=1 result[x][y]=c c+=1 result[y][x]=c c+=1 result[y][N-1-x]=c c+=1 result[N-1-x][y]=c x,y=N-1-x,y t=1 if count%2==0: if result[x][y+1]>0: count+=1 x-=1 else: y+=1 else: if result[x][y-1]>0: count+=1 x-=1 else: y-=1 else: if x==y or x==N-1-y: c+=1 result[x][y]=c if c==N**2: break c+=1 a,b=N-1-x,N-1-y result[a][b]=c c+=1 a,b=x,N-1-y result[a][b]=c c+=1 a,b=N-1-x,y result[a][b]=c t=0 x,y=N-1-x,y if count%2==0: y+=1 else: y-=1 else: c+=1 result[x][y]=c c+=1 result[y][x]=c c+=1 result[y][N-1-x]=c c+=1 result[N-1-x][y]=c x,y=N-1-x,y t=0 if count%2==0: if result[x][y+1]>0: count+=1 x+=1 else: y+=1 else: if result[x][y-1]>0: count+=1 x+=1 else: y-=1 for i in range(N): print(*result[i])