結果
| 問題 |
No.1267 Stop and Coin Game
|
| コンテスト | |
| ユーザー |
IKyopro
|
| 提出日時 | 2020-10-23 22:30:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,088 bytes |
| コンパイル時間 | 1,740 ms |
| コンパイル使用メモリ | 196,588 KB |
| 最終ジャッジ日時 | 2025-01-15 13:28:32 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << (x) << endl;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
ll V;
cin >> N >> V;
vec<ll> A(N);
for(auto& x:A) cin >> x;
if(accumulate(all(A),0LL)<=V){
cout << "Draw\n";
return 0;
}
vec<int> dp(1<<N,-1);
auto check = [&](int S){
ll s = 0;
for(int i=0;i<N;i++) if(S>>i&1) s += A[i];
return s>V;
};
auto rec = [&](auto&& self,int S){
if(check(S)) return 1;
if(dp[S]!=-1) return dp[S];
int res = 0;
for(int i=0;i<N;i++) if(!(S>>i)&1) res |= !self(self,S^(1<<i));
return dp[S] = res;
};
cout << (rec(rec,0)? "First\n":"Second\n");
}
IKyopro