結果

問題 No.715 集合と二人ゲーム
ユーザー ats5515ats5515
提出日時 2017-09-12 17:41:26
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,252 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 80,908 KB
実行使用メモリ 16,904 KB
最終ジャッジ日時 2024-04-28 15:56:57
合計ジャッジ時間 8,525 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,756 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 6 ms
6,944 KB
testcase_10 AC 6 ms
6,940 KB
testcase_11 AC 8 ms
6,944 KB
testcase_12 AC 9 ms
6,940 KB
testcase_13 AC 10 ms
6,940 KB
testcase_14 AC 9 ms
6,944 KB
testcase_15 AC 11 ms
6,944 KB
testcase_16 AC 12 ms
6,940 KB
testcase_17 AC 10 ms
6,940 KB
testcase_18 AC 15 ms
6,940 KB
testcase_19 AC 15 ms
6,940 KB
testcase_20 AC 15 ms
6,940 KB
testcase_21 AC 17 ms
6,944 KB
testcase_22 AC 18 ms
6,940 KB
testcase_23 AC 19 ms
6,944 KB
testcase_24 AC 20 ms
6,944 KB
testcase_25 AC 20 ms
6,940 KB
testcase_26 AC 21 ms
6,940 KB
testcase_27 AC 24 ms
6,940 KB
testcase_28 AC 26 ms
6,940 KB
testcase_29 AC 26 ms
6,940 KB
testcase_30 AC 375 ms
6,940 KB
testcase_31 AC 322 ms
6,944 KB
testcase_32 AC 217 ms
6,940 KB
testcase_33 AC 498 ms
6,940 KB
testcase_34 AC 405 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 1 ms
6,940 KB
testcase_38 AC 2 ms
6,944 KB
testcase_39 AC 1 ms
6,944 KB
testcase_40 AC 1 ms
6,940 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 2 ms
6,944 KB
testcase_43 AC 1 ms
6,940 KB
testcase_44 AC 2 ms
6,944 KB
testcase_45 AC 1 ms
6,940 KB
testcase_46 AC 2 ms
6,940 KB
testcase_47 AC 1 ms
6,944 KB
testcase_48 AC 2 ms
6,940 KB
testcase_49 AC 1 ms
6,940 KB
testcase_50 TLE -
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
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;
}
0