結果

問題 No.3323 岩井星式ジャンケン
コンテスト
ユーザー GOTKAKO
提出日時 2025-11-03 04:37:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,238 bytes
コンパイル時間 1,922 ms
コンパイル使用メモリ 201,008 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-03 04:37:49
合計ジャッジ時間 3,820 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N,M; cin >> N >> M;
    vector<string> S(N);
    for(auto &s : S) cin >> s;

    string answer = "";
    vector<int> A(N);
    for(int i=0; i<N; i++) A.at(i) = i;
    for(int k=0; k<M; k++){
        int s = 0;
        for(auto i : A){
            if(S.at(i).at(k) == 'G') s |= 1;
            if(S.at(i).at(k) == 'C') s |= 2;
            if(S.at(i).at(k) == 'P') s |= 4;
        }
        if(s == 0){answer += 'P'; A.clear(); continue;}
        if(s == 1){answer += 'P'; A.clear(); continue;}
        if(s == 2){answer += 'G'; A.clear(); continue;}
        if(s == 4){answer += 'C'; A.clear(); continue;}
        if(s == 7){cout << -1 << endl; return 0;}
        vector<int> B;
        if(s == 3) answer += 'G';
        if(s == 5) answer += 'P';
        if(s == 6) answer += 'C';
        for(auto i : A){
            if(S.at(i).at(k) == 'G' && s == 3) B.push_back(i);
            if(S.at(i).at(k) == 'C' && s == 6) B.push_back(i);
            if(S.at(i).at(k) == 'P' && s == 5) B.push_back(i);
        }
        swap(A,B);
    }
    if(A.size()){cout << -1 << endl; return 0;}
    cout << answer << endl;
}
0