結果

問題 No.2521 Don't be Same
ユーザー navel_tosnavel_tos
提出日時 2023-10-28 01:52:34
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,559 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 82,388 KB
平均クエリ数 10.57
最終ジャッジ日時 2023-10-28 01:52:40
合計ジャッジ時間 5,730 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
70,004 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 104 ms
70,004 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 98 ms
69,732 KB
testcase_11 AC 99 ms
69,732 KB
testcase_12 AC 101 ms
69,732 KB
testcase_13 AC 100 ms
69,732 KB
testcase_14 AC 100 ms
69,732 KB
testcase_15 AC 98 ms
69,732 KB
testcase_16 AC 99 ms
69,732 KB
testcase_17 AC 95 ms
69,732 KB
testcase_18 AC 102 ms
69,732 KB
testcase_19 AC 99 ms
69,732 KB
testcase_20 AC 102 ms
69,732 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 106 ms
70,004 KB
testcase_26 RE -
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder410G Dont be Same

#愚直解を作成する。0~N個の石ではじまる場合のmexを求める(mex>0なら先手必勝)
def simple(N):
    DP=[[-1]*(N+1) for _ in range(N+1)]
    HS,WS=[[set() for _ in range(N+1)] for _ in range(2)]  #行と列のセット
    for h in range(N+1):
        DP[h][0]=h; WS[0].add(h); HS[h].add(h)
        for w in range(1,N+1):
            check=HS[h]|WS[w]
            if h==w: check|=set([DP[i][i] for i in range(h)])
            for i in range(10**10):
                if i not in check: DP[h][w]=i; break
            HS[h].add(DP[h][w]); WS[w].add(DP[h][w])
    return [(h,w) for h in range(N+1) for w in range(N+1) if DP[h][w]==0]

#実験すると、小さい方が奇数 かつ もう片方は+1 の場合のみ先手必敗とわかる
#ジャッジに必敗形を押しつけるゲームを楽しめばよさそうだ
def recieve(text,X,Y):
    if text[0]=='A':
        _,i,x=text.split(); i=int(i); x=int(x)
        return (X-x,Y) if i==1 else (X,Y-x)
    if text[0]=='B': return (0,0)
    else: exit()

X,Y=map(int,input().split())
if (X+1==Y and X%2) or (X==Y+1 and Y%2):
    print('Second'); T=input(); X,Y=recieve(T,X,Y)
else: print('First')

#必敗形を押しつける
while 1:
    if X==Y: print('B'); X=Y=0; exit()
    elif X<Y:
        if X%2: diff=Y-X-1; Y-=diff; print('A 2',diff)
        else:   diff=Y-X+1; Y-=diff; print('A 2',diff)
    else:
        if Y%2: diff=X-Y-1; X-=diff; print('A 1',diff)
        else:   diff=X-Y+1; X-=diff; print('A 1',diff)
    T=input(); X,Y=recieve(T,X,Y)
0