結果
問題 | No.715 集合と二人ゲーム |
ユーザー |
![]() |
提出日時 | 2017-09-11 21:51:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 176 ms / 2,000 ms |
コード長 | 1,312 bytes |
コンパイル時間 | 984 ms |
コンパイル使用メモリ | 85,492 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 09:22:27 |
合計ジャッジ時間 | 6,579 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 60 |
ソースコード
#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 longsigned main() {int Nmax = 200;vector<int>G(Nmax + 1);G[0] = 0;G[1] = 1;G[2] = 1;set<int> st;int t = 0;for (int i = 3; i <= Nmax; i++) {st.clear();st.insert(G[i - 2]);st.insert(G[i - 3]);for (int j = 0; i - 4 - j > 0; j++) {st.insert(G[i - 4 - j] ^ G[j + 1]);}t = 0;G[i] = -1;for (auto s : st) {if (t != s) {G[i] = t;break;}t++;}if (G[i] == -1) G[i] = t;}int A[100];int B[34];for (int i = 0; i <= Nmax; i++) {if (i < 100) {A[i] = G[i];}else {B[(i - 100) % 34] = 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 seq = 1;int Grundy = 0;for (int i = 0; i < N - 1; i++) {if (a[i] + 1 == a[i + 1]) {seq++;}else {if (seq < 100) {Grundy ^= A[seq];}else {Grundy ^= B[(seq - 100) % 34];}seq = 1;}}if (seq < 100) {Grundy ^= A[seq];}else {Grundy ^= B[(seq - 100) % 34];}if (Grundy > 0) {cout << "First" << endl;}else {cout << "Second" << endl;}return 0;}