結果
| 問題 |
No.3323 岩井星式ジャンケン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-01 15:53:24 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 1,366 bytes |
| コンパイル時間 | 11,865 ms |
| コンパイル使用メモリ | 399,980 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-11-01 15:53:45 |
| 合計ジャッジ時間 | 14,054 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
use proconio::{input, marker::Chars};
fn main() {
input! {
n: usize,
m: usize,
s: [Chars; n],
}
let mut flag = vec![false; n];
let mut ans = vec![];
for j in 0..m {
let mut ng = true;
let mut max_wins = (0, '_');
'outer: for hand in ['G', 'C', 'P'] {
let mut wins = 0;
for i in 0..n {
if flag[i] {
continue;
}
match (hand, s[i][j]) {
('G', 'P') | ('P', 'C') | ('C', 'G') => {
continue 'outer;
}
('G', 'C') | ('P', 'G') | ('C', 'P') => wins += 1,
_ => continue,
}
}
ng = false;
if max_wins.0 <= wins {
max_wins = (wins, hand);
}
}
if ng {
println!("-1");
return;
}
let (_, hand) = max_wins;
ans.push(hand);
for i in 0..n {
match (hand, s[i][j]) {
('G', 'C') | ('P', 'G') | ('C', 'P') => flag[i] = true,
_ => continue,
}
}
}
if flag.iter().any(|&x| !x) {
println!("-1");
return;
}
for i in ans {
print!("{}", i);
}
println!("");
}