結果

問題 No.2103 ±1s Game
ユーザー titia
提出日時 2022-10-22 06:14:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,137 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-01 11:34:54
合計ジャッジ時間 2,301 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

sys.setrecursionlimit(10**7)

from functools import lru_cache
@lru_cache(maxsize=None)
def game(X,Y,te,now,P):
    #print(X,Y)
    if X+Y<K-3 and X+Y>10:
        X%=2
        Y%=2
        
        return game(X,Y,te,now,P)

    if X+Y>K+3:
        minus=(X+Y-K+3)

        minusX=minus*X//(X+Y)//2*2
        minusY=minus*Y//(X+Y)//2*2
        X-=minusX
        Y-=minusY

        return game(X,Y,te,now,P)
        
    if X+Y==K:
        if now==P:
            return te
        else:
            return te^1

    if te==1:
        ANS=0
        
        if X>0:
            if game(X-1,Y,te^1,now,P)==1:
                ANS=1
        if Y>0:
            if game(X,Y-1,te^1,-now,P)==1:
                ANS=1

        return ANS

    else:
        ANS=1
        
        if X>0:
            if game(X-1,Y,te^1,now,P)==0:
                ANS=0
        if Y>0:
            if game(X,Y-1,te^1,-now,P)==0:
                ANS=0

        return ANS


X,Y,K,P=map(int,input().split())

now=1
if Y%2==-1:
    now=-1

ANS=game(X,Y,0,now,P)

if ANS==0:
    print("Alice")
else:
    print("Bob")
            
0