結果

問題 No.1267 Stop and Coin Game
ユーザー butsurizukibutsurizuki
提出日時 2020-10-23 22:38:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 896 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 32,236 KB
実行使用メモリ 7,068 KB
最終ジャッジ日時 2023-09-28 16:45:54
合計ジャッジ時間 4,147 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,012 KB
testcase_01 AC 4 ms
7,024 KB
testcase_02 AC 3 ms
7,024 KB
testcase_03 AC 3 ms
7,052 KB
testcase_04 WA -
testcase_05 AC 4 ms
6,912 KB
testcase_06 AC 4 ms
7,048 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
7,016 KB
testcase_10 AC 70 ms
7,016 KB
testcase_11 AC 33 ms
7,008 KB
testcase_12 WA -
testcase_13 AC 3 ms
6,968 KB
testcase_14 AC 3 ms
7,060 KB
testcase_15 AC 4 ms
7,008 KB
testcase_16 AC 156 ms
7,016 KB
testcase_17 AC 3 ms
7,020 KB
testcase_18 AC 4 ms
6,972 KB
testcase_19 AC 4 ms
7,008 KB
testcase_20 AC 3 ms
7,032 KB
testcase_21 AC 4 ms
7,032 KB
testcase_22 AC 4 ms
6,972 KB
testcase_23 AC 4 ms
7,036 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 4 ms
7,052 KB
testcase_27 WA -
testcase_28 AC 6 ms
7,016 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 5 ms
6,964 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 6 ms
7,012 KB
testcase_41 WA -
testcase_42 AC 4 ms
6,888 KB
testcase_43 WA -
testcase_44 AC 307 ms
6,884 KB
testcase_45 AC 3 ms
6,952 KB
testcase_46 AC 4 ms
7,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

int n;
long long a[32];
int mem[1048576];
int rep(int fl,int tr,long long lef){
  if(lef<0){return tr;}
  if(fl==0){return 0;}
  if(lef==0){return -tr;}
  if(mem[fl]!=-100){return mem[fl];}
  int mo=0,z=0,po=0;
  for(int i=0;i<n;i++){
    if((fl&(1<<i))==0){continue;}
    if(rep(fl^(1<<i),-tr,lef-a[i])==-1){mo=1;}
    if(rep(fl^(1<<i),-tr,lef-a[i])==0){z=1;}
    if(rep(fl^(1<<i),-tr,lef-a[i])==1){po=1;}
  }
  if(tr==1){
    if(po==1){mem[fl]=1;}
    else if(z==1){mem[fl]=0;}
    else{mem[fl]=-1;}
  }
  else{
    if(mo==1){mem[fl]=1;}
    else if(z==1){mem[fl]=0;}
    else{mem[fl]=-1;}
  }
  return mem[fl];
}

int main(){
  long long v;
  scanf("%d%lld",&n,&v);
  for(int i=0;i<n;i++){scanf("%d",&a[i]);}
  for(int i=0;i<1048576;i++){mem[i]=-100;}
  int k=rep((1<<n)-1,1,v);
  if(k==-1){puts("Second");}
  if(k==0){puts("Draw");}
  if(k==1){puts("First");}
  return 0;
}
0