結果
問題 | No.715 集合と二人ゲーム |
ユーザー |
![]() |
提出日時 | 2018-07-26 15:28:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,356 bytes |
コンパイル時間 | 1,534 ms |
コンパイル使用メモリ | 172,804 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 03:19:32 |
合計ジャッジ時間 | 7,005 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 WA * 22 |
ソースコード
#include <bits/stdc++.h>#define rep(n) for(int i=0;i<n;i++)#define repp(j, n) for(int j=0;j<n;j++)#define reppp(i, m, n) for(int i=m;i<n;i++)#define all(c) c.begin(), c.end()#define rall(c) c.rbegin(), c.rend()#define debug(x) cerr << #x << ": " << x << endlusing namespace std;typedef long long ll;typedef pair<ll, ll> Pll;typedef pair<int, int> Pii;const ll MOD = 1000000007;const long double EPS = 10e-10;struct Game{map<int, int> mp;Game(int n){dfs(n);}int dfs(int n){if(n <= 0) return 0;else if(mp[n] != 0) return mp[n];set<int> used;used.insert(dfs(n-2));used.insert(dfs(n-3));for(int i=3;i<=(n+1)/2;i++){used.insert(dfs(i-2)^dfs(n-(i+1)));}int g = 0;while(used.find(g) != used.end()) g++;mp[n] = g;return g;}};int main(){std::ios::sync_with_stdio(0); cin.tie(0);Game game = Game(80);int n;cin >> n;int a[n];rep(n) cin >> a[i];sort(a, a+n);int m = 1, grundy = 0;reppp(i, 1, n){if(a[i] - a[i-1] <= 1){m++;}else{if(m > 80) m -= m/34*34;grundy ^= game.mp[m];m = 1;}}if(m > 1) grundy ^= game.mp[m];cout << (grundy?"First":"Second") << endl;}