結果

問題 No.380 悪の台本
ユーザー phsplsphspls
提出日時 2020-06-20 17:19:22
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 1,029 bytes
コンパイル時間 1,857 ms
コンパイル使用メモリ 146,824 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 17:38:47
合計ジャッジ時間 1,550 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 RE -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn end_pattern(talk: &str, matcher: &str) -> bool {
    let length = talk.len();
    let temp = talk.rfind(matcher);
    temp.is_some() && temp.unwrap() + 3 + 3 >= length
}

fn main() {
    let mut all_data = String::new();
    std::io::stdin().read_to_string(&mut all_data).ok();
    let talks: Vec<_> = all_data.trim().split('\n').map(|s| s.trim().to_ascii_lowercase()).collect();

    for t in talks.iter() {
        let (talker, talk) = t.split_at(5);
        let mut flg = false;
        match talker {
            "digi " => { flg = end_pattern(talk, "nyo"); },
            "petit" => { flg = end_pattern(talk.trim(), "nyu"); },
            "rabi " => { flg = talk.chars().filter(|c| c.is_ascii_alphanumeric()).count() > 0; },
            "gema " => { flg = end_pattern(talk, "gema"); },
            "piyo " => { flg = end_pattern(talk, "pyo"); },
            _ => {},
        }
        if flg {
            println!("CORRECT (maybe)");
        } else {
            println!("WRONG!");
        }
    }
}
0