結果
| 問題 |
No.3323 岩井星式ジャンケン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-15 00:57:36 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 2,390 bytes |
| コンパイル時間 | 13,537 ms |
| コンパイル使用メモリ | 399,188 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-11-15 00:57:51 |
| 合計ジャッジ時間 | 12,121 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
use proconio::{fastout, input, marker::Bytes};
#[fastout]
fn main() {
input! {
n: usize,
m: usize,
s: [Bytes; n],
}
println!("{}", output(solve(n, m, s)));
}
fn solve(n: usize, m: usize, mut s: Vec<Vec<u8>>) -> Option<String> {
let mut ans = String::with_capacity(m);
for i in 0..m {
let mut count_g = 0;
let mut count_c = 0;
let mut count_p = 0;
for j in 0..n {
match s[j].get(i) {
Some(b'G') => count_g += 1,
Some(b'C') => count_c += 1,
Some(b'P') => count_p += 1,
_ => (),
};
}
let (count_g, count_c, count_p) = (count_g, count_c, count_p);
if count_g == 0 {
if count_p == 0 {
ans.push_str(&String::from("G").repeat(m - i));
return Some(ans);
}
if count_c == 0 {
ans.push_str(&String::from("C").repeat(m - i));
return Some(ans);
}
ans.push('C');
for j in 0..n {
match s[j].get(i) {
Some(b'P') => s[j].clear(),
_ => (),
}
}
} else if count_c == 0 {
if count_g == 0 {
ans.push_str(&String::from("C").repeat(m - i));
return Some(ans);
}
if count_p == 0 {
ans.push_str(&String::from("P").repeat(m - i));
return Some(ans);
}
ans.push('P');
for j in 0..n {
match s[j].get(i) {
Some(b'G') => s[j].clear(),
_ => (),
}
}
} else if count_p == 0 {
if count_c == 0 {
ans.push_str(&String::from("P").repeat(m - i));
return Some(ans);
}
if count_g == 0 {
ans.push_str(&String::from("G").repeat(m - i));
}
ans.push('G');
for j in 0..n {
match s[j].get(i) {
Some(b'C') => s[j].clear(),
_ => (),
}
}
}
}
None
}
fn output(ans: Option<String>) -> String {
match ans {
Some(s) => s,
None => String::from("-1"),
}
}