結果

問題 No.3323 岩井星式ジャンケン
コンテスト
ユーザー Rumain831
提出日時 2026-08-29 08:49:20
言語 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  
実行時間 -
コード長 821 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,979 ms
コンパイル使用メモリ 179,008 KB
実行使用メモリ 7,224 KB
最終ジャッジ日時 2026-08-29 08:49:27
合計ジャッジ時間 4,818 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main(void){
  int n, m; cin >> n >> m;
  vector<string> s(n);
  vector<int> rem;
  for(int i=0; i<n; i++){
    cin >> s[i];
    rem.push_back(i);
  }
  string ans(m, 'G');
  auto f=[&](int a[3]){
    if(a[0]==0) return 'C';
    if(a[1]==0) return 'P';
    if(a[2]==0) return 'G';
    return '!';
  };
  for(int i=0; i<m; i++){
    vector<int> old;
    swap(old, rem);
    int cnt[3]={};
    for(auto p:old){
      if(s[p][i]=='G') cnt[0]++;
      else if(s[p][i]=='C') cnt[1]++;
      else cnt[2]++;
    }
    char x=f(cnt);
    if(x=='!'){
      cout << -1 << endl; return 0;
    }
    ans[i]=x;
    for(auto p:old)if(s[p][i]==x) rem.push_back(p);
    if(rem.empty()) break;
  }
  cout << ans << endl;
  return 0; 
}
0