結果

問題 No.715 集合と二人ゲーム
ユーザー ats5515ats5515
提出日時 2017-09-12 00:16:14
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,194 bytes
コンパイル時間 862 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-04-28 15:53:09
合計ジャッジ時間 9,142 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,888 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 6 ms
6,940 KB
testcase_03 AC 10 ms
6,944 KB
testcase_04 AC 14 ms
6,940 KB
testcase_05 AC 19 ms
6,940 KB
testcase_06 AC 22 ms
6,944 KB
testcase_07 AC 29 ms
6,944 KB
testcase_08 AC 38 ms
6,944 KB
testcase_09 AC 45 ms
6,944 KB
testcase_10 AC 47 ms
6,940 KB
testcase_11 AC 59 ms
6,940 KB
testcase_12 AC 73 ms
6,940 KB
testcase_13 AC 84 ms
6,940 KB
testcase_14 AC 92 ms
6,940 KB
testcase_15 AC 111 ms
6,944 KB
testcase_16 AC 114 ms
6,940 KB
testcase_17 AC 101 ms
6,940 KB
testcase_18 AC 142 ms
6,940 KB
testcase_19 AC 162 ms
6,940 KB
testcase_20 AC 151 ms
6,940 KB
testcase_21 AC 184 ms
6,944 KB
testcase_22 AC 209 ms
6,944 KB
testcase_23 AC 225 ms
6,944 KB
testcase_24 AC 256 ms
6,940 KB
testcase_25 AC 247 ms
6,940 KB
testcase_26 AC 242 ms
6,944 KB
testcase_27 AC 285 ms
6,944 KB
testcase_28 AC 339 ms
6,940 KB
testcase_29 AC 347 ms
6,940 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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
signed main() {

	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;
	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 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;
}
0