結果
問題 | No.1267 Stop and Coin Game |
ユーザー |
|
提出日時 | 2020-11-14 01:36:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 200 ms / 2,000 ms |
コード長 | 688 bytes |
コンパイル時間 | 2,941 ms |
コンパイル使用メモリ | 198,776 KB |
最終ジャッジ日時 | 2025-01-16 00:21:48 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int N; { cin >> N; }int64_t V; { cin >> V; }vector<int64_t> A(N); { for (int i = 0; i < N; ++i) cin >> A[i]; }int64_t s = accumulate(A.begin(), A.end(), (int64_t) 0);if (s <= V) { cout << "Draw" << endl; return 0; }vector<int> d(1 << N, -1); {function<int(int64_t, int)> dfs = [&](int64_t v, int s) {if (~d[s]) return d[s];d[s] = 0;for (int i = 0; i < N; ++i) if (s >> i & 1) {if (A[i] <= v) {d[s] |= !dfs(v - A[i], s ^ 1 << i);}}return d[s];};dfs(V, (1 << N) - 1);}cout << (d[(1 << N) - 1] ? "First" : "Second") << endl;}