結果
問題 |
No.715 集合と二人ゲーム
|
ユーザー |
![]() |
提出日時 | 2017-09-12 17:41:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,252 bytes |
コンパイル時間 | 1,350 ms |
コンパイル使用メモリ | 80,884 KB |
実行使用メモリ | 16,616 KB |
最終ジャッジ日時 | 2024-11-17 09:28:43 |
合計ジャッジ時間 | 36,541 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 TLE * 10 |
ソースコード
#include <iostream> #include <vector> #include <map> #include <set> #include <string> #include <iomanip> #include <algorithm> #include <cmath> #include <stdio.h> using namespace std; #define int long long int G[500005]; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) { cin >> a[i]; } sort(a.begin(), a.end()); int seq = 1; int maxseq = 1; vector<int> cnt; for (int i = 0; i < N - 1; i++) { if (a[i] + 1 == a[i + 1]) { seq++; } else { cnt.push_back(seq); maxseq = max(maxseq, seq); seq = 1; } } cnt.push_back(seq); maxseq = max(maxseq, seq); int Nmax = maxseq; G[0] = 0; G[1] = 1; G[2] = 1; int st[11]; int t = 0; for (int i = 3; i <= Nmax; i++) { for (int j = 0; j < 11; j++) { st[j] = 0; } st[G[i - 2]] = 1; st[G[i - 3]] = 1; for (int j = 0; i - 4 - j > j; j++) { t = G[i - 4 - j] ^ G[j + 1]; if (t < 11) { st[t] = 1; } } t = 0; for (int j = 0; j < 11; j++) { if (st[j] == 0) { G[i] = j; break; } } } int Grundy = 0; for (int i = 0; i < cnt.size(); i++) { Grundy ^= G[cnt[i]]; } if (Grundy > 0) { cout << "First" << endl; } else { cout << "Second" << endl; } return 0; }