結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-28 15:10:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 599 bytes |
| コンパイル時間 | 365 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 59,136 KB |
| 最終ジャッジ日時 | 2024-12-28 15:10:06 |
| 合計ジャッジ時間 | 3,077 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
def rotate(tup:tuple[int,int])->tuple:
return (tup[1],-tup[0])
def main():
N=int(input())
field=[[0 for i in range(N)] for j in range(N)]
_count=1
x=0
y=0
field[y][x]=_count
_count+=1
direction=(0,1)
while _count<=N*N:
if x+direction[0]<0 or x+direction[0]>=N or y+direction[1]<0 or y+direction[1]>=N or field[y+direction[1]][x+direction[0]]!=0:
direction=rotate(direction)
x+=direction[0]
y+=direction[1]
field[y][x]=_count
_count+=1
field=zip(*field)
for row in field:
print(*map(lambda x:f"{x:03}",row))
if __name__=="__main__":
main()