結果
| 問題 | No.3323 岩井星式ジャンケン |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-15 11:04:02 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,669 bytes |
| 記録 | |
| コンパイル時間 | 3,287 ms |
| コンパイル使用メモリ | 176,340 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-15 11:04:09 |
| 合計ジャッジ時間 | 6,215 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 6 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:73:13: warning: 'beat' may be used uninitialized [-Wmaybe-uninitialized]
73 | if (s[j][i] == beat) won[j] = true;
| ^~
main.cpp:17:10: note: 'beat' was declared here
17 | char beat;
| ^~~~
ソースコード
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
vector<string> s(n);
for (int i = 0; i < n; i++)
cin >> s[i];
vector<bool> won(n, false);
bool g, c, p;
string ans = "";
char beat;
for (int i = 0; i < m; i++)
{
g = c = p = false;
for (int j = 0; j < n; j++)
{
if (won[j])
continue;
if (s[j][i] == 'G')
g = true;
if (s[j][i] == 'C')
c = true;
if (s[j][i] == 'P')
p = true;
}
if (g + c + p == 1)
{
if (g) {
ans.push_back('P');
beat = 'G';
}
if (c) {
ans.push_back('G');
beat = 'C';
}
if (p) {
ans.push_back('C');
beat = 'P';
}
}
else if (g + c + p == 2)
{
if (g && c){
ans.push_back('G');
beat = 'C';
}
if (c && p) {
ans.push_back('C');
beat = 'P';
}
if (p && g) {
ans.push_back('P');
beat = 'G';
}
}
else if (g + c + p == 3)
{
cout << -1 << endl;
return 0;
}
else
{
ans.push_back('G');
beat = 'P';
}
for (int j = 0; j < n; j++)
if (s[j][i] == beat) won[j] = true;
}
cout << ans << endl;
return 0;
}