結果
| 問題 |
No.3323 岩井星式ジャンケン
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2025-11-10 11:51:08 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 1,708 bytes |
| コンパイル時間 | 3,032 ms |
| コンパイル使用メモリ | 284,852 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-11-10 11:51:13 |
| 合計ジャッジ時間 | 4,849 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; }
bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; }
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M;
cin >> N >> M;
vector<string> S(N);
for (int i = 0; i < N; i++) cin >> S[i];
vector<int> I(N);
iota(I.begin(), I.end(), 0);
string ans;
for (int j = 0; j < M; j++) {
int G = 0, C = 0, P = 0;
for (int i : I) {
G |= (S[i][j] == 'G');
C |= (S[i][j] == 'C');
P |= (S[i][j] == 'P');
}
int T = G + C + P;
if (T == 3) {
cout << -1 << endl;
return 0;
} else if (T == 2) {
vector<int> J;
if (!G) {
ans.push_back('C');
for (int i : I) {
if (S[i][j] == 'C') J.push_back(i);
}
} else if (!C) {
ans.push_back('P');
for (int i : I) {
if (S[i][j] == 'P') J.push_back(i);
}
} else {
ans.push_back('G');
for (int i : I) {
if (S[i][j] == 'G') J.push_back(i);
}
}
I = J;
} else if (T == 1) {
if (G) {
ans.push_back('P');
} else if (C) {
ans.push_back('G');
} else {
ans.push_back('C');
}
I.clear();
} else {
ans.push_back('G');
}
}
cout << (I.size() ? "-1" : ans) << endl;
}
nonon