結果

問題 No.3323 岩井星式ジャンケン
コンテスト
ユーザー The_Bouningeeeen
提出日時 2025-11-01 15:51:10
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 1,285 bytes
コンパイル時間 13,771 ms
コンパイル使用メモリ 397,424 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-11-01 15:51:44
合計ジャッジ時間 15,611 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

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,
            }
        }
    }

    for i in ans {
        print!("{}", i);
    }
    println!("");
}
0