結果
| 問題 | 
                            No.197 手品
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-04-26 15:13:38 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 1,000 ms | 
| コード長 | 1,688 bytes | 
| コンパイル時間 | 11,582 ms | 
| コンパイル使用メモリ | 378,304 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-20 04:02:21 | 
| 合計ジャッジ時間 | 12,916 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 43 | 
ソースコード
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();
    if n == 0 {
        let u: String = s.into_iter().collect();
        let v: String = t.into_iter().collect();
        if u == v {
            println!("FAILURE");
        } else {
            println!("SUCCESS");
        }
    } else {
        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')
                        || (s[1] == 'o' && t[1] == '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')
                        || (s[1] == 'x' && t[1] == 'x'))
                {
                    println!("SUCCESS");
                } else {
                    println!("FAILURE");
                }
            } else {
                println!("FAILURE");
            }
        }
    }
}