結果

問題 No.197 手品
ユーザー phspls
提出日時 2020-05-21 00:10:29
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 952 bytes
コンパイル時間 13,595 ms
コンパイル使用メモリ 378,460 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 04:02:39
合計ジャッジ時間 15,112 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

fn xcount(s: &Vec<char>) -> usize {
    s.iter().filter(|c| **c == 'x').count()
}

fn main() {
    let mut s1 = String::new();
    std::io::stdin().read_line(&mut s1).ok();
    let s1: Vec<char> = s1.trim().chars().collect();
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut s2 = String::new();
    std::io::stdin().read_line(&mut s2).ok();
    let s2: Vec<char> = s2.trim().chars().collect();

    if xcount(&s1) != xcount(&s2) {
        println!("SUCCESS");
    } else if n == 0 {
        println!("{}", if s1.iter().zip(s2.iter()).filter(|pair| pair.0 == pair.1).count() == 3 { "FAILURE" } else { "SUCCESS" });
    } else if n == 1 {
        if (xcount(&s1) == 1 || xcount(&s1) == 2) && s1[1] == s2[1] && s1[0] == s2[2] {
            println!("SUCCESS");
        } else {
            println!("FAILURE");
        }
    } else {
        println!("FAILURE");
    }
}
0