結果

問題 No.3323 岩井星式ジャンケン
コンテスト
ユーザー 抹茶フォルマッジ
提出日時 2026-09-04 22:24:47
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 3,020 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,781 ms
コンパイル使用メモリ 389,816 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2026-09-04 22:25:24
合計ジャッジ時間 7,340 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:136:17: warning: multi-character character constant [-Wmultichar]
  136 |         cout << '-1\n';
      |                 ^~~~~~

ソースコード

diff #
raw source code

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using mint = modint998244353;
// using mint = modint1000000007;

constexpr ll INF = (1LL << 60);
constexpr int INF32 = (1 << 30);

template<typename T> using vc = vector<T>;
template<typename T> using vv = vector<vector<T>>;

using vi = vc<int>;
using vvi = vv<int>;
using vl = vc<ll>;
using vvl = vv<ll>;
using vs = vc<string>;
using vvs = vv<string>;
using vb = vc<bool>;
using vvb = vv<bool>;
using vmint = vc<mint>;
using vvmint = vv<mint>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define drep(i,n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rrep(i,n) for(ll i=1; i<=(ll)(n); i++)
#define nfor(i,a,b) for(ll i=(ll)(a); i<(ll)(b); i++)
#define dfor(i,a,b) for(ll i=(ll)(a)-1; i>=(ll)(b); i--)

#define nall(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

template<class T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& x : v) is >> x;
    return is;
}

template<class T, class U>
istream& operator>>(istream& is, pair<T,U>& p) {
    return is >> p.first >> p.second;
}

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void YES() { cout << "Yes\n"; }
void NO()  { cout << "No\n"; }

void yn(bool ok) {
    cout << (ok ? "Yes" : "No") << '\n';
}

template<class T>
void print(const vector<T>& v) {
    for (int i = 0; i < (int)v.size(); i++) {
        if (i) cout << ' ';
        cout << v[i];
    }
    cout << '\n';
}

template<class T>
void print(const vector<vector<T>>& v) {
    for (const auto& row : v) {
        print(row);
    }
}

void print(ld x) {
    cout << fixed << setprecision(20) << x << '\n';
}

int main() {
    int N, M;
    cin >> N >> M;
    vs S(N);
    cin >> S;
    vi beat(N,0);
    string ans = "";
    rep(i,M) {
        int g = 0;
        int p = 0;
        int c = 0;
        
        rep(j,N) {
            if(beat[j]==1) continue;
            if(S[j][i]=='G') g = 1;
            if(S[j][i]=='P') p = 1;
            if(S[j][i]=='C') c = 1;
        }

        if(g*p*c==1) {
            cout << "-1\n";
            return 0;
        }

        if(g==1&&p==1) ans.push_back('P');
        else if(c==1&&p==1) ans.push_back('C');
        else if(g==1&&c==1) ans.push_back('G');
        else if(g==1) ans.push_back('P');
        else if(c==1) ans.push_back('G');
        else ans.push_back('C');

        rep(j,N) {
            if(ans.back()=='G' && S[j][i]=='C') beat[j] = 1;
            if(ans.back()=='P' && S[j][i]=='G') beat[j] = 1;
            if(ans.back()=='C' && S[j][i]=='P') beat[j] = 1;
            
        }
    }
    rep(i,N) if(beat[i]==0) {
        cout << '-1\n';
    } else cout << ans << "\n";
}
0