結果
問題 | No.1267 Stop and Coin Game |
ユーザー |
|
提出日時 | 2020-10-23 23:00:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 149 ms / 2,000 ms |
コード長 | 1,106 bytes |
コンパイル時間 | 2,654 ms |
コンパイル使用メモリ | 195,772 KB |
最終ジャッジ日時 | 2025-01-15 13:48:57 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:18:35: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 3 has type ‘i64*’ {aka ‘long int*’} [-Wformat=] 18 | int n; i64 V; scanf("%d%lld", &n, &V); | ~~~^ ~~ | | | | | i64* {aka long int*} | long long int* | %ld main.cpp:20:35: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 2 has type ‘long int*’ [-Wformat=] 20 | for(auto& v: a) scanf("%lld", &v); | ~~~^ ~~ | | | | | long int* | long long int* | %ld main.cpp:18:28: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | int n; i64 V; scanf("%d%lld", &n, &V); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp:20:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | for(auto& v: a) scanf("%lld", &v); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>using namespace std::literals::string_literals;using i64 = std::int_fast64_t;using std::cout;using std::cerr;using std::endl;using std::cin;template<typename T>std::vector<T> make_v(size_t a){return std::vector<T>(a);}template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}int main() {int n; i64 V; scanf("%d%lld", &n, &V);std::vector<i64> a(n);for(auto& v: a) scanf("%lld", &v);if(V - std::accumulate(begin(a), end(a), 0LL) >= 0) {printf("Draw\n");return 0;}std::vector<i64> sum(1 << n);for(int i = 0; i < (1 << n); i++) {for(int j = 0; j < n; j++) {if(!(i >> j & 1)) continue;sum[i] += a[j];}}std::vector<int> dp(1 << n, 2);for(int i = (1 << n) - 1; i >= 0; i--) {if(V - sum[i] < 0) {dp[i] = 1;continue;}for(int k = 0; k < n; k++) {if(i >> k & 1) continue;int to = i | (1 << k);if(dp[to] == 0) dp[i] = 1;}if(dp[i] == 2) dp[i] = 0;}if(dp[0]) printf("First\n");else printf("Second\n");return 0;}