結果
問題 |
No.643 Two Operations No.2
|
ユーザー |
![]() |
提出日時 | 2024-06-25 01:51:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 692 bytes |
コンパイル時間 | 206 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2024-06-25 01:51:21 |
合計ジャッジ時間 | 1,114 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 2 |
ソースコード
from collections import deque X,Y=map(int,input().split()) DP=[[10**6]*300 for i in range(300)] # DP[0][0] は(-150,-150) Q=deque() for i in range(300): DP[i][i]=0 Q.append((i,i)) while Q: x,y=Q.popleft() x1=x-150 y1=y-150 if DP[y][x]>DP[x][y]+1: DP[y][x]=DP[x][y]+1 Q.append((y,x)) if (x1+y1)%2==0: x2=(x1+y1)//2 y2=(x1-y1)//2 #print(x1,y1,x2,y2) if 0<=x2+150<300 and 0<=y2+150<300 and DP[x2+150][y2+150]>DP[x][y]+1: DP[x2+150][y2+150]=DP[x][y]+1 Q.append((x2+150,y2+150)) if DP[X-150][Y-150]>=10**5: print(-1) else: print(DP[X-150][Y-150])