結果

問題 No.2814 Block Game
ユーザー とりゐとりゐ
提出日時 2024-07-19 23:18:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,674 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 81,960 KB
実行使用メモリ 78,136 KB
最終ジャッジ日時 2024-07-19 23:18:21
合計ジャッジ時間 17,050 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
61,568 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

memo={}
def naive(n,c0,c1,d0,d1,f):
  if n==0:
    return f==0
  if (c0,c1,d0,d1,f) in memo:
    return memo[(c0,c1,d0,d1,f)]
  mex=set()
  if c0>0 and d0>0:
    mex.add(naive(n-1,c0-1,c1,d0-1,d1,f^1))
  
  if c1>0 and d0>0:
    mex.add(naive(n-1,c0,c1-1,d0-1,d1,f^1))
  if c0>0 and d1>0:
    mex.add(naive(n-1,c0-1,c1,d0,d1-1,f^1))
  if c1>0 and d1>0:
    mex.add(naive(n-1,c0,c1-1,d0,d1-1,f))
  
  g=0
  while g in mex:
    g+=1
  memo[(c0,c1,d0,d1,f)]=g
  return g

def check(n,c0,c1,d0,d1,f):
  if min(c0,c1,d0,d1)==0:
    if c0==0:
      sm=d1%2
    elif c1==0:
      sm=0
    elif d0==0:
      sm=c1%2
    else:
      sm=0
    return (sm&1)==f
  if n%2==1:
    return True
  if min(c0,c1,d0,d1)==1:
    return True
  return False

if 1:
  for n in range(1,9):
    for c0 in range(n+1):
      for d0 in range(n+1):
        for f in range(2):
          c1=n-c0
          d1=n-d0

          
          #print((n,c0,c1,d0,d1,f),naive(n,c0,c1,d0,d1,f))
          # if naive(n,c0,c1,d0,d1,f)==0:
          #   if min(c0,c1,d0,d1)>=1:
          #     print("lose",n,(c0,c1,d0,d1,f))
          # elif min(c0,c1,d0,d1)>=1:
          #   print("win",n,(c0,c1,d0,d1,f))

          ans1=(naive(n,c0,c1,d0,d1,f)>=1)
          ans2=check(n,c0,c1,d0,d1,f)
          if ans1!=ans2:
            print(n,(c0,c1,d0,d1,f),ans1,ans2)

def binom(n,r):
  return int((n&r)==r)

def count(n):
  c=0
  for i in range(60):
    if (n>>i)&1:
      c+=1
  return 1<<c

def solve(n,s):
  f=(s=="Even")
  c1=count(n)
  c0=n-c1
  d0=n//2
  d1=(n+1)//2
  
  if check(n,c0,c1,d0,d1,f):
    print("Alice")
  else:
    print("Bob")
  

for _ in range(int(input())):
  n,s=input().split()
  solve(int(n),s)
0