結果

問題 No.715 集合と二人ゲーム
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2018-07-13 23:18:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,335 bytes
コンパイル時間 1,708 ms
コンパイル使用メモリ 119,964 KB
実行使用メモリ 16,500 KB
最終ジャッジ日時 2024-04-17 11:31:12
合計ジャッジ時間 32,707 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 33 ms
5,376 KB
testcase_04 AC 55 ms
5,376 KB
testcase_05 AC 82 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 152 ms
5,760 KB
testcase_08 AC 207 ms
5,888 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 360 ms
6,468 KB
testcase_12 AC 481 ms
6,400 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 771 ms
7,040 KB
testcase_16 AC 803 ms
7,168 KB
testcase_17 AC 689 ms
7,204 KB
testcase_18 WA -
testcase_19 AC 1,210 ms
7,680 KB
testcase_20 AC 1,086 ms
8,064 KB
testcase_21 WA -
testcase_22 AC 1,599 ms
8,448 KB
testcase_23 WA -
testcase_24 TLE -
testcase_25 AC 1,922 ms
9,088 KB
testcase_26 WA -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
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 <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

vector<int> uf, usz;
int nc;

void init(int n){
  vector<int> uf_(n);
  vector<int> usz_(n, 1);
  uf = uf_;
  usz = usz_;
  nc = n;

  for(int i = 0; i < uf.size(); i++){
    uf[i] = i;
  }
}

int find(int a){
  return (uf[a] == a) ? a : uf[a] = find(uf[a]);
}

void union_(int a, int b){
  a = find(a);
  b = find(b);

  if(a != b){
    if(usz[a] >= usz[b]){
      swap(a, b);
    }
    uf[a] = b;
    usz[b] += usz[a];
    nc--;
  }
}

int check(int a, int b){
  return (find(a) == find(b)) ? 1 : 0;
}

int get_size(int a){
  return usz[find(a)];
}

ll dp[100100];

int f(int n){
  if(dp[n]!=-1)return dp[n];
  if(n == 0)return 0; 
  set<int> se;
  if(n == 1)se.insert(f(n-1));
  if(n >= 2)se.insert(f(n-2));
  if(n >= 3)se.insert(f(n-3));
  if(n>=5){
  	set<pair<ll,ll> > sep;
  	rep(i,1,n){
  		ll a = i;
  		ll b = n-3-i;
  		if(b>0){
  			if(a>b)swap(a,b);
  			sep.insert(mp(a,b));
  		}
  	}
  	vector<pair<ll,ll> > vp;
  	rep(i,0,vp.sz){
  		se.insert(f(vp[i].fi)^f(vp[i].se));
  	}
  }
  int g = 0;
  while(se.count(g)!=0)g++;
  return dp[n] = g;
}

int main(void) {
	clr(dp,-1);
	ll n;
	cin>>n;
	set<ll> se;
	rep(i,0,n){
		ll a;
		cin>>a;
		se.insert(a);
	}
	vector<ll> v(all(se));
	init(v.sz);
	rep(i,0,v.sz-1){
		if(v[i]==v[i+1]-1){
			union_(i,i+1);
		}
	}
	set<ll> se1;
	rep(i,0,v.sz){
		se1.insert(find(i));
	}
	vector<ll> v1(all(se1));
	vector<ll> v2;
	rep(i,0,v1.sz){
		v2.pb(get_size(v1[i]));
	}
	ll ans = 0;
	rep(i,0,v2.sz){
		ans ^=f(v2[i]);
	}
	if(ans!=0){
		cout << "First" << endl;
	}
	else{
		cout << "Second" << endl;
	}
	return 0;
}
0