結果
| 問題 |
No.715 集合と二人ゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-13 22:42:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 593 ms / 2,000 ms |
| コード長 | 744 bytes |
| コンパイル時間 | 706 ms |
| コンパイル使用メモリ | 77,836 KB |
| 実行使用メモリ | 7,168 KB |
| 最終ジャッジ日時 | 2024-10-09 05:20:52 |
| 合計ジャッジ時間 | 30,191 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 60 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int g[500001];
int main() {
g[1] = 1;
g[2] = 1;
for (int i = 3; i <= 500000; i++) {
long long st = 0;
st |= 1LL << g[i - 2];
for (int j = 0; j <= min(800, i - 3); j++) {
st |= 1LL << (g[j] ^ g[i - 3 - j]);
}
while (st >> g[i] & 1) {
g[i]++;
}
}
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
int cnt = 1;
int ans = 0;
for (int i = 1; i < n; i++) {
if (a[i - 1] + 1 == a[i]) {
cnt++;
} else {
ans ^= g[cnt];
cnt = 1;
}
}
ans ^= g[cnt];
cout << (ans != 0 ? "First" : "Second") << endl;
}