結果

問題 No.3586 Divide and Be Conquered
コンテスト
ユーザー kotatsugame
提出日時 2026-07-10 21:54:47
言語 C++14
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 1,190 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 633 ms
コンパイル使用メモリ 104,700 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-10 21:54:53
合計ジャッジ時間 2,841 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cassert>
using namespace std;
map<vector<int>,bool>memo;
bool naive(vector<int>A)
{
	if(A.empty())return false;
	sort(A.begin(),A.end());
	if(memo.find(A)!=memo.end())return memo[A];
	bool win=false;
	for(int i=0;i<A.size();i++)
	{
		assert(A[i]>=2);
		int x=A[i];
		auto test=[&](int a){
			vector<int>B=A;
			B.erase(B.begin()+i);
			if(a>=2)B.push_back(a);
			return naive(B);
		};
		bool out=false;
		for(int a=1;a+a<=x;a++)
		{
			int b=x-a;
			if(test(a)&&test(b))
			{
				out=true;
				break;
			}
		}
		if(!out)
		{
			win=true;
			break;
		}
	}
	return memo[A]=win;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	/*
	const int L=30;
	vector<int>win;
	for(int a=2;a<=L;a++)
	{
		if(naive({a}))
		{
			cout<<"win : "<<a<<endl;
			win.push_back(a);
		}
	}
	for(int x:win)for(int y:win)if(x<y)
	{
		cout<<"["<<x<<", "<<y<<"] : "<<naive({x,y})<<endl;
	}
	*/
	int T;cin>>T;
	for(;T--;)
	{
		int N;cin>>N;
		int win=0,three=0;
		for(;N--;)
		{
			long a;cin>>a;
			if(a==3)three++;
			else if(a%10==2||a%10==3||a%10==7||a%10==8)win++;
		}
		cout<<(win%2||three%2?"First\n":"Second\n");
	}
}
0