結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー 👑 zeronosu77108zeronosu77108
提出日時 2023-08-04 21:45:36
言語 Rust
(1.77.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 3,049 bytes
コンパイル時間 11,905 ms
コンパイル使用メモリ 408,488 KB
実行使用メモリ 15,752 KB
最終ジャッジ日時 2024-05-10 07:17:37
合計ジャッジ時間 14,095 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 22 ms
9,660 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 37 ms
15,752 KB
testcase_06 AC 12 ms
6,016 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 AC 13 ms
6,872 KB
testcase_10 AC 22 ms
9,396 KB
testcase_11 AC 12 ms
6,032 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 13 ms
8,088 KB
testcase_14 AC 22 ms
12,376 KB
testcase_15 AC 15 ms
8,064 KB
testcase_16 AC 6 ms
5,376 KB
testcase_17 AC 16 ms
9,600 KB
testcase_18 AC 13 ms
7,552 KB
testcase_19 AC 18 ms
11,008 KB
testcase_20 AC 16 ms
9,600 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 8 ms
5,760 KB
testcase_23 AC 8 ms
5,376 KB
testcase_24 AC 9 ms
5,632 KB
testcase_25 AC 17 ms
10,752 KB
testcase_26 AC 9 ms
5,888 KB
testcase_27 AC 17 ms
11,248 KB
testcase_28 AC 14 ms
8,320 KB
testcase_29 AC 9 ms
5,760 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 18 ms
11,520 KB
testcase_32 AC 8 ms
5,504 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 6 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut sc = Scanner::new();
    let n = sc.usize();
    let k = sc.usize();
    let a = sc.nvec::<usize>();
    let b = sc.nvec::<usize>();

    let mut d = vec![false; n + 1];
    for &a in a.iter() { d[a] = true; }

    let mut c = vec![false; n + 1];
    for &b in b.iter() { c[b] = true; }

    let mut dp = vec![vec![false; 2]; n+1];
    dp[0][0] = true;

    for i in 0..n {
        for j in vec![1, k] {
            if i + j > n { continue; }
            if d[i + j] {
                dp[i+j][1] |= dp[i][0];
                dp[i+j][1] |= dp[i][1];
            } else if c[i + j] {
                dp[i+j][0] |= dp[i][1];
                dp[i+j][0] |= dp[i][0];
            } else {
                dp[i+j][0] |= dp[i][0];
                dp[i+j][1] |= dp[i][1];
            }
        }
    }


    println!("{}", if dp[n][0] { "Yes" } else { "No" });
}


struct Scanner { s : std::collections::VecDeque<String> } #[allow(unused)] impl Scanner { fn new() -> Self { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); Self { s : s.split_whitespace().map(|s| s.to_string()).collect() } } fn reload(&mut self) -> () { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); self.s = s.split_whitespace().map(|s| s.to_string()).collect(); } fn usize(&mut self) -> usize { self.input() } fn usize1(&mut self) -> usize { self.input::<usize>() - 1 } fn isize(&mut self) -> isize { self.input() } fn i32(&mut self) -> i32 { self.input() } fn i64(&mut self) -> i64 { self.input() } fn i128(&mut self) -> i128 { self.input() } fn u8(&mut self) -> u8 { self.input() } fn u32(&mut self) -> u32 { self.input() } fn u64(&mut self) -> u64 { self.input() } fn u128(&mut self) -> u128 { self.input() } fn edge(&mut self) -> (usize, usize) { (self.usize1(), self.usize1()) } fn edges(&mut self, m : usize) -> Vec<(usize, usize)> { let mut e = Vec::with_capacity(m); for _ in 0..m { e.push(self.edge()); } e } fn wedge<T:std::str::FromStr>(&mut self) -> (usize, usize, T) { (self.usize1(), self.usize1(), self.input()) } fn wedges<T:std::str::FromStr>(&mut self, m : usize) -> Vec<(usize, usize, T)> { let mut e = Vec::with_capacity(m); for _ in 0..m { e.push(self.wedge()); } e } fn input<T>(&mut self) -> T where T: std::str::FromStr { if self.s.is_empty() { self.reload(); } if let Some(head) = self.s.pop_front() { head.parse::<T>().ok().unwrap() } else { panic!() } } fn tuple<T, U>(&mut self) -> (T, U) where T: std::str::FromStr, U: std::str::FromStr { (self.input(), self.input()) } fn vec<T>(&mut self, n: usize) -> Vec<T> where T: std::str::FromStr { if self.s.is_empty() { self.reload(); } self.s.drain(..n).map(|s| s.parse::<T>().ok().unwrap() ).collect::<Vec<T>>() } fn nvec<T>(&mut self) -> Vec<T> where T: std::str::FromStr { let n : usize = self.input(); self.vec(n) } fn chars(&mut self) -> Vec<char> { let s : String = self.input(); s.chars().collect() } fn bytes(&mut self) -> Vec<u8> { let s : String = self.input(); s.bytes().collect() } }
0