結果

問題 No.380 悪の台本
ユーザー phsplsphspls
提出日時 2020-06-20 17:41:23
言語 Rust
(1.72.1)
結果
WA  
実行時間 -
コード長 1,435 bytes
コンパイル時間 1,712 ms
コンパイル使用メモリ 148,640 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 17:40:45
合計ジャッジ時間 2,204 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

use std::io::Read;

fn end_pattern(talk: String, matcher: &str) -> bool {
    let length = talk.len();
    let temp = talk.rfind(matcher);
    temp.is_some()
    && temp.unwrap() + matcher.len() + 3 >= length
    && talk.chars()
        .filter(|c| c.is_ascii_alphanumeric())
        .map(|c| c.to_string())
        .collect::<Vec<String>>()
        .join("")
        .ends_with(matcher)
}

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').collect();

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