結果

問題 No.1267 Stop and Coin Game
ユーザー butsurizukibutsurizuki
提出日時 2020-10-23 22:40:31
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 898 bytes
コンパイル時間 998 ms
コンパイル使用メモリ 29,208 KB
実行使用メモリ 5,976 KB
最終ジャッジ日時 2023-09-28 16:51:59
合計ジャッジ時間 3,098 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,944 KB
testcase_01 AC 3 ms
5,864 KB
testcase_02 AC 3 ms
5,872 KB
testcase_03 AC 3 ms
5,948 KB
testcase_04 AC 3 ms
5,800 KB
testcase_05 AC 3 ms
5,944 KB
testcase_06 AC 3 ms
5,812 KB
testcase_07 AC 3 ms
5,940 KB
testcase_08 AC 4 ms
5,944 KB
testcase_09 AC 3 ms
5,768 KB
testcase_10 AC 66 ms
5,876 KB
testcase_11 AC 30 ms
5,828 KB
testcase_12 AC 8 ms
5,808 KB
testcase_13 AC 3 ms
5,944 KB
testcase_14 AC 3 ms
5,876 KB
testcase_15 AC 3 ms
5,940 KB
testcase_16 AC 141 ms
5,744 KB
testcase_17 AC 3 ms
5,948 KB
testcase_18 AC 3 ms
5,804 KB
testcase_19 AC 3 ms
5,804 KB
testcase_20 AC 2 ms
5,936 KB
testcase_21 AC 3 ms
5,944 KB
testcase_22 AC 3 ms
5,808 KB
testcase_23 AC 3 ms
5,872 KB
testcase_24 AC 7 ms
5,796 KB
testcase_25 AC 110 ms
5,952 KB
testcase_26 AC 3 ms
5,872 KB
testcase_27 AC 3 ms
5,868 KB
testcase_28 AC 5 ms
5,864 KB
testcase_29 AC 3 ms
5,808 KB
testcase_30 AC 3 ms
5,872 KB
testcase_31 AC 4 ms
5,884 KB
testcase_32 AC 2 ms
5,744 KB
testcase_33 AC 3 ms
5,888 KB
testcase_34 AC 77 ms
5,800 KB
testcase_35 AC 3 ms
5,920 KB
testcase_36 AC 4 ms
5,804 KB
testcase_37 AC 22 ms
5,976 KB
testcase_38 AC 171 ms
5,888 KB
testcase_39 AC 12 ms
5,876 KB
testcase_40 AC 5 ms
5,868 KB
testcase_41 AC 14 ms
5,948 KB
testcase_42 AC 3 ms
5,768 KB
testcase_43 AC 25 ms
5,944 KB
testcase_44 AC 246 ms
5,868 KB
testcase_45 AC 3 ms
5,876 KB
testcase_46 AC 3 ms
5,876 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("%lld",&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