Submission #2973604

Source Code Expand

Copy
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn solve(s:&str) -> bool {
    let mut n = s.len(); 
    loop {
        if n == 0 {
            return true;
        } else if n >= 5 && unsafe { s.slice_unchecked(n-5, n) == "dream" } {
            n -= 5;
        } else if n >= 7 && unsafe { s.slice_unchecked(n-7, n) == "dreamer" } {
            n -= 7;
        } else if n >= 5 && unsafe { s.slice_unchecked(n-5, n) == "erase" } {
            n -= 5;
        } else if n >= 6 && unsafe { s.slice_unchecked(n-6, n) == "eraser" } {
            n -= 6;
        } else {
            return false;
        }
    }
}
fn main() {
    let s = read::<String>();
    if solve(&s) {
        println!("YES");
    } else {
        println!("NO");
    }
}

Submission Info

Submission Time
Task ABC049C - 白昼夢 / Daydream
User naoya_t
Language Rust (1.15.1)
Score 300
Code Size 881 Byte
Status
Exec Time 2 ms
Memory 4352 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
All 300 / 300 subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt
Case Name Status Exec Time Memory
subtask0_0.txt 2 ms 4352 KB
subtask0_1.txt 2 ms 4352 KB
subtask0_2.txt 2 ms 4352 KB
subtask1_0.txt 2 ms 4352 KB
subtask1_1.txt 2 ms 4352 KB
subtask1_10.txt 2 ms 4352 KB
subtask1_11.txt 2 ms 4352 KB
subtask1_12.txt 2 ms 4352 KB
subtask1_13.txt 2 ms 4352 KB
subtask1_14.txt 2 ms 4352 KB
subtask1_15.txt 2 ms 4352 KB
subtask1_2.txt 2 ms 4352 KB
subtask1_3.txt 2 ms 4352 KB
subtask1_4.txt 2 ms 4352 KB
subtask1_5.txt 2 ms 4352 KB
subtask1_6.txt 2 ms 4352 KB
subtask1_7.txt 2 ms 4352 KB
subtask1_8.txt 2 ms 4352 KB
subtask1_9.txt 2 ms 4352 KB