結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
69,732 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 102 ms
69,732 KB
testcase_11 AC 103 ms
69,732 KB
testcase_12 AC 102 ms
69,732 KB
testcase_13 AC 103 ms
69,732 KB
testcase_14 AC 102 ms
69,732 KB
testcase_15 AC 103 ms
69,732 KB
testcase_16 AC 100 ms
69,732 KB
testcase_17 AC 101 ms
69,732 KB
testcase_18 AC 103 ms
69,732 KB
testcase_19 AC 101 ms
69,732 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
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'); X,Y=recieve(input(),X,Y)
else: print('First')

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