結果

問題 No.3323 岩井星式ジャンケン
コンテスト
ユーザー Rumain831
提出日時 2026-11-01 20:56:29
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 965 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,819 ms
コンパイル使用メモリ 187,168 KB
実行使用メモリ 9,864 KB
最終ジャッジ日時 2026-11-01 20:56:33
合計ジャッジ時間 4,254 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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);
  for(auto&x:s) cin >> x;
  string ans(m, 'G');
  vector<int> wait;
  for(int i=0; i<n; i++) wait.push_back(i);
  for(int i=0; i<m; i++){
    vector<int> old;
    swap(old, wait);
    int now=0;
    for(auto p:old){
      int x=(s[p][i]=='G'?0:(s[p][i]=='C'?1:2));
      now|=(1<<x);
    }
    int k=__builtin_popcount(now);
    if(k==3){
      cout << -1 << endl; return 0;
    }
    else if(k==1){
      ans[i]=(now==1?'P':(now==2?'G':'P'));
      cout << ans << endl; return 0;
    }
    else if(k==2){
      char win=(now==3?'G':(now==5?'P':'C'));
      char lose=(now==3?'C':(now==5?'G':'P'));
      ans[i]=win;
      for(auto p:old){
        if(s[p][i]==win) wait.push_back(p);
      }
    }
    else break;
  }
  if(wait.empty()) cout << ans << endl;
  else cout << -1 << endl;
  return 0; 
}
0