結果
| 問題 |
No.3323 岩井星式ジャンケン
|
| コンテスト | |
| ユーザー |
のらら
|
| 提出日時 | 2025-10-31 00:22:24 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,620 bytes |
| コンパイル時間 | 3,326 ms |
| コンパイル使用メモリ | 185,280 KB |
| 実行使用メモリ | 11,496 KB |
| 最終ジャッジ日時 | 2025-10-31 00:22:29 |
| 合計ジャッジ時間 | 5,085 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 9 WA * 11 |
ソースコード
//入力チェック+解が確定するjを求める
#include <iostream>
#include <algorithm>
#include <atcoder/all>
#include <set>
using namespace std;
using namespace atcoder;
using ll = long long;
//#define endl "\n";
ll N, M, chk[100009];
string S[100009];
vector<char> ans;
vector<char> te = {'G', 'C', 'P'};
set<ll> rest;
void dfs(ll pos){
if(pos == M){
if(rest.size() == 0){
for(auto s: ans) cout << s;
cout << endl;
exit(0);
}else{
return;
}
}
vector<ll> visited(3, true);
for(int k = 0; k < 3; k++){
for(auto itr = rest.begin(); itr != rest.end(); ++itr){
if(S[*itr][pos] == te[(k + 2) % 3]){
visited[k] = false;
}
}
if(visited[k]){
vector<ll> tmp;
for(auto itr = rest.begin(); itr != rest.end(); ++itr){
if(S[*itr][pos] == te[(k + 1) % 3]){
tmp.push_back(*itr);
}
}
if(tmp.size() == 0 && rest.size() > 0) continue; //あいこにする必要はない
ans.push_back(te[k]);
for(auto p: tmp) rest.erase(p);
if(rest.size() == 0){
cout << "idx=" << pos + 1 << endl;
exit(0);
}
dfs(pos + 1);
for(auto p: tmp) rest.insert(p);
ans.pop_back();
}
}
}
int main(){
cin >> N >> M;
assert(1 <= N && N <= 1e5);
assert(1 <= M && M <= 1e5);
assert(1 <= N * M && N * M<= 1e5);
for(int i = 0; i < N; i++){
cin >> S[i];
assert(S[i].size() == M);
for(int j = 0; j < M; j++){
assert(S[i][j] == 'G' || S[i][j] == 'C' || S[i][j] == 'P');
}
rest.insert(i);
}
dfs(0);
cout << -1 << endl;
return 0;
}
のらら