結果
| 問題 | No.3586 Divide and Be Conquered |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-11 07:46:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,440 bytes |
| 記録 | |
| コンパイル時間 | 1,575 ms |
| コンパイル使用メモリ | 236,152 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-11 07:46:56 |
| 合計ジャッジ時間 | 5,764 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 WA * 1 TLE * 1 -- * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
random_device rnd;
mt19937 mt(rnd());
int solve(vector<long long> A){
map<pair<vector<long long>,bool>,int> memo;
auto dfs = [&](auto dfs,vector<long long> X,bool first) -> int {
sort(X.begin(),X.end());
if(X.back() == 1) return first?0:1;
if(memo.count({X,first})) return memo[{X,first}];
bool win = !first;
for(int i=0; i<X.size(); i++) if(X.at(i) != 1){
bool ok = true;
for(long long a=1; ; a++){
long long b = X.at(i)-a;
if(a > b) break;
X.at(i) = a;
bool one = dfs(dfs,X,first^1);
X.at(i) = b;
bool two = dfs(dfs,X,first^1);
X.at(i) = a+b;
if(one == first || two == first) continue;
ok = false; break;
}
if(ok){win = first; break;}
}
return memo[{X,first}] = win;
};
auto f = [&](auto f,int pos) -> void {
if(pos == A.size()) dfs(dfs,A,true),dfs(dfs,A,false);
else for(int i=0; i<A.size(); i++) A.at(pos) = i+1,f(f,pos+1);
};
f(f,0);
int ret = dfs(dfs,A,true);
set<vector<long long>> look;
for(auto [k,v] : memo) if(!look.count(k.first)){
auto V = k.first;
look.insert(k.first);
while(V.size() != A.size()) V.insert(V.begin(),1);
int now1 = 0,now2 = 0;
for(auto v : V) cout << v << " ",now1 ^= v%5==2,now2 ^= v%5==3;
cout << " " << (v^k.second^1) << "," << (now1|now2) << endl;
}
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while(T--){
int N; cin >> N;
int now1 = 0,now2 = 0;
while(N--){
int a; cin >> a;
if(a%5 == 2) now1 ^= 1;
if(a%5 == 3) now2 ^= 2;
}
if(now1+now2) cout << "First" << endl;
else cout << "Second" << endl;
}
return 0;
{
int n; cin >> n;
vector<int> V(n+1);
V.at(1) = 0;
for(int i=2; i<=n; i++){
int win = 1;
for(int a=1; a<=i; a++){
int b = i-a;
if(a > b) break;
if(V.at(a) && V.at(b)){win = 0; break;}
}
V.at(i) = win;
}
V.erase(V.begin());
for(auto v : V) cout << v; cout << endl;
}
}