結果

問題 No.197 手品
ユーザー tonyu0
提出日時 2020-04-26 15:08:02
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 1,111 bytes
コンパイル時間 13,649 ms
コンパイル使用メモリ 378,708 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 07:29:11
合計ジャッジ時間 15,464 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let s: Vec<char> = itr.next().unwrap().chars().collect();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let t: Vec<char> = itr.next().unwrap().chars().collect();

    let a = s
        .iter()
        .fold(0, |acc, x| if *x == 'o' { acc + 1 } else { acc });
    let b = t
        .iter()
        .fold(0, |acc, x| if *x == 'o' { acc + 1 } else { acc });
    if a != b {
        println!("SUCCESS",)
    } else {
        if a == 1 {
            if n == 1 && ((s[0] == 'o' && t[2] == 'o') || (s[2] == 'o' && t[0] == 'o')) {
                println!("SUCCESS");
            } else {
                println!("FAILURE");
            }
        } else if a == 2 {
            if n == 1 && ((s[0] == 'x' && t[2] == 'x') || (s[2] == 'x' && t[0] == 'x')) {
                println!("SUCCESS");
            } else {
                println!("FAILURE");
            }
        } else {
            println!("FAILURE");
        }
    }
}
0