結果

問題 No.683 Two Operations No.3
ユーザー lam6er
提出日時 2025-03-20 21:09:07
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 731 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,348 KB
実行使用メモリ 596,252 KB
最終ジャッジ日時 2025-03-20 21:09:59
合計ジャッジ時間 4,337 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 MLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def solve():
    A, B = map(int, input().split())
    q = deque([(A, B)])
    visited = set()
    while q:
        a, b = q.popleft()
        if a == 0 and b == 0:
            print("Yes")
            return
        # Check for operation 1 reverse
        if a % 2 == 0 and b >= 1:
            na = a // 2
            nb = b - 1
            if (na, nb) not in visited:
                visited.add((na, nb))
                q.append((na, nb))
        # Check for operation 2 reverse
        if b % 2 == 0 and a >= 1:
            na = a - 1
            nb = b // 2
            if (na, nb) not in visited:
                visited.add((na, nb))
                q.append((na, nb))
    print("No")

solve()
0