結果

問題 No.2373 wa, wo, n
ユーザー rp523rp523
提出日時 2023-07-08 01:00:48
言語 Rust
(1.77.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 2,739 bytes
コンパイル時間 5,582 ms
コンパイル使用メモリ 141,688 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 02:33:42
合計ジャッジ時間 7,866 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 33 ms
4,380 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 35 ms
4,376 KB
testcase_17 AC 10 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 39 ms
4,376 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 47 ms
4,376 KB
testcase_35 AC 4 ms
4,380 KB
testcase_36 AC 31 ms
4,376 KB
testcase_37 AC 26 ms
4,380 KB
testcase_38 AC 26 ms
4,376 KB
testcase_39 AC 46 ms
4,376 KB
testcase_40 AC 33 ms
4,376 KB
testcase_41 AC 34 ms
4,376 KB
testcase_42 AC 26 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_macros, unused_imports, dead_code)]
use std::any::TypeId;
use std::cmp::{max, min, Ordering, Reverse};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};

mod procon_reader {
    use std::fmt::Debug;
    use std::io::Read;
    use std::str::FromStr;
    pub fn read<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let stdin = std::io::stdin();
        let mut stdin_lock = stdin.lock();
        let mut u8b: [u8; 1] = [0];
        loop {
            let mut buf: Vec<u8> = Vec::with_capacity(16);
            loop {
                let res = stdin_lock.read(&mut u8b);
                if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                    break;
                } else {
                    buf.push(u8b[0]);
                }
            }
            if !buf.is_empty() {
                let ret = String::from_utf8(buf).unwrap();
                return ret.parse().unwrap();
            }
        }
    }
    pub fn read_vec<T: std::str::FromStr>(n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| read::<T>()).collect::<Vec<T>>()
    }
    pub fn read_vec_sub1(n: usize) -> Vec<usize> {
        (0..n).map(|_| read::<usize>() - 1).collect::<Vec<usize>>()
    }
    pub fn read_mat<T: std::str::FromStr>(h: usize, w: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..h).map(|_| read_vec::<T>(w)).collect::<Vec<Vec<T>>>()
    }
}
use procon_reader::*;
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut dp = vec![false; n + 1];
    dp[0] = true;
    for i in 0..n {
        if !dp[i] {
            continue;
        }
        for key in vec!["wa", "wo", "n"].iter() {
            let key = key.to_string().chars().collect::<Vec<_>>();
            if i + key.len() > n {
                continue;
            }
            let mut mch = true;
            for ki in 0..key.len() {
                if key[ki] == s[i + ki] {
                    continue;
                }
                if s[i + ki] == '?' {
                    continue;
                }
                mch = false;
                break;
            }
            if !mch {
                continue;
            }
            dp[i + key.len()] = true;
        }
    }
    if dp[n] {
        println!("Yes");
    } else {
        println!("No");
    }
}
0