結果
| 問題 |
No.3323 岩井星式ジャンケン
|
| コンテスト | |
| ユーザー |
おもち(求肥)
|
| 提出日時 | 2025-11-01 15:59:40 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 1,499 bytes |
| コンパイル時間 | 12,493 ms |
| コンパイル使用メモリ | 398,612 KB |
| 実行使用メモリ | 8,184 KB |
| 最終ジャッジ日時 | 2025-11-01 16:00:02 |
| 合計ジャッジ時間 | 14,260 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
use std::collections::HashSet;
use proconio::input;
use proconio::marker::Chars;
fn main() {
input!{
n: usize,
m: usize,
s: [Chars; n]
}
let mut ans = vec![];
let mut remain = vec![0; n];
for i in 0..n {
remain[i] = i;
}
let mut win = false;
for i in 0..m {
let mut hands = HashSet::new();
for &j in &remain {
hands.insert(s[j][i]);
}
if hands.len() == 3 {
println!("-1");
return;
}
if hands.len() == 2 {
if !hands.contains(&'G') {
remain = remain.into_iter().filter(|&h| s[h][i] == 'C').collect();
ans.push('C');
}
if !hands.contains(&'C') {
remain = remain.into_iter().filter(|&h| s[h][i] == 'P').collect();
ans.push('P');
}
if !hands.contains(&'P') {
remain = remain.into_iter().filter(|&h| s[h][i] == 'G').collect();
ans.push('G');
}
}
if hands.len() == 1 {
win = true;
if hands.contains(&'G') { ans.push('P'); break;}
if hands.contains(&'C') { ans.push('G'); break;}
if hands.contains(&'P') { ans.push('C'); break;}
}
}
if !win { println!("-1"); return;}
while ans.len() < m {
ans.push('G');
}
println!("{}", ans.iter().fold(String::new(), |mut acc, &c| {acc.push(c); acc}));
}
おもち(求肥)