結果

問題 No.2521 Don't be Same
ユーザー navel_tosnavel_tos
提出日時 2023-10-28 01:56:00
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,671 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 81,528 KB
実行使用メモリ 82,184 KB
平均クエリ数 9.46
最終ジャッジ日時 2023-10-28 01:56:19
合計ジャッジ時間 17,061 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 957 ms
69,792 KB
testcase_09 AC 1,058 ms
69,792 KB
testcase_10 AC 100 ms
69,732 KB
testcase_11 AC 100 ms
69,732 KB
testcase_12 AC 97 ms
69,732 KB
testcase_13 AC 96 ms
69,732 KB
testcase_14 AC 96 ms
69,732 KB
testcase_15 AC 99 ms
69,732 KB
testcase_16 AC 100 ms
69,732 KB
testcase_17 AC 96 ms
69,732 KB
testcase_18 AC 103 ms
69,732 KB
testcase_19 AC 98 ms
69,732 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 957 ms
69,792 KB
testcase_23 AC 303 ms
69,792 KB
testcase_24 RE -
testcase_25 AC 756 ms
69,792 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()


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

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