結果
問題 | No.715 集合と二人ゲーム |
ユーザー |
|
提出日時 | 2018-07-14 00:04:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 183 ms / 2,000 ms |
コード長 | 1,578 bytes |
コンパイル時間 | 1,098 ms |
コンパイル使用メモリ | 114,644 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-09 05:49:01 |
合計ジャッジ時間 | 5,406 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 60 |
ソースコード
#define _USE_MATH_DEFINES#include <cstdio>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <algorithm>#include <cmath>#include <complex>#include <string>#include <vector>#include <array>#include <list>#include <queue>#include <stack>#include <set>#include <map>#include <bitset>#include <numeric>#include <limits>#include <climits>#include <cfloat>#include <functional>#include <iterator>using namespace std;const int LOOP = 68;void solve(vector<int>& grundy){grundy.assign(2*LOOP+1, 0);grundy[0] = 0;grundy[1] = 1;grundy[2] = 1;for(int i=3; i<=2*LOOP; ++i){set<int> s;s.insert(grundy[i-2]);int a = 0;int b = i - 3;while(a <= b){s.insert(grundy[a] ^ grundy[b]);++ a;-- b;}for(const int x : s){if(grundy[i] != x)break;++ grundy[i];}}}int main(){int n;cin >> n;vector<int> v(n);for(int i=0; i<n; ++i)cin >> v[i];sort(v.begin(), v.end());vector<int> grundy;solve(grundy);int i = 0;int ans = 0;while(i < n){int len = 1;++ i;while(i < n && v[i] == v[i-1] + 1){++ len;++ i;}if(len <= LOOP)ans ^= grundy[len];elseans ^= grundy[LOOP+(len-1)%LOOP+1];}if(ans == 0)cout << "Second" << endl;elsecout << "First" << endl;return 0;}