結果

問題 No.1456 Range Xor
ユーザー RheoTommyRheoTommy
提出日時 2021-03-31 21:21:55
言語 Rust
(1.77.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 3,262 bytes
コンパイル時間 3,111 ms
コンパイル使用メモリ 162,412 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2023-08-21 22:38:27
合計ジャッジ時間 5,646 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 22 ms
8,348 KB
testcase_04 AC 22 ms
8,448 KB
testcase_05 AC 22 ms
8,340 KB
testcase_06 AC 22 ms
8,420 KB
testcase_07 AC 24 ms
8,440 KB
testcase_08 AC 22 ms
8,344 KB
testcase_09 AC 22 ms
8,420 KB
testcase_10 AC 21 ms
8,416 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 8 ms
4,524 KB
testcase_14 AC 8 ms
4,480 KB
testcase_15 AC 18 ms
8,032 KB
testcase_16 AC 17 ms
7,648 KB
testcase_17 AC 11 ms
5,172 KB
testcase_18 AC 8 ms
4,508 KB
testcase_19 AC 15 ms
6,928 KB
testcase_20 AC 17 ms
7,720 KB
testcase_21 AC 14 ms
6,780 KB
testcase_22 AC 15 ms
6,924 KB
testcase_23 AC 8 ms
4,640 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 7 ms
4,380 KB
testcase_26 AC 12 ms
5,424 KB
testcase_27 AC 16 ms
7,272 KB
testcase_28 AC 6 ms
4,380 KB
testcase_29 AC 21 ms
8,736 KB
testcase_30 AC 21 ms
9,088 KB
testcase_31 AC 6 ms
4,376 KB
testcase_32 AC 5 ms
4,380 KB
testcase_33 AC 9 ms
4,860 KB
testcase_34 AC 20 ms
8,952 KB
testcase_35 AC 11 ms
5,092 KB
testcase_36 AC 21 ms
8,088 KB
testcase_37 AC 20 ms
8,224 KB
testcase_38 AC 5 ms
4,376 KB
testcase_39 AC 16 ms
7,504 KB
testcase_40 AC 17 ms
7,444 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 4 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

// # ファイル構成
// - use 宣言
// - lib モジュール
// - main 関数
// - basic モジュール
//
// 常に使うテンプレートライブラリは basic モジュール内にあります。
// 問題に応じて使うライブラリ lib モジュール内にコピペしています。
// ライブラリのコードはこちら → https://github.com/RheoTommy/at_coder
// Twitter はこちら → https://twitter.com/RheoTommy

use std::collections::*;
use std::io::{stdout, BufWriter, Write};

use crate::basic::*;
use crate::lib::*;

pub mod lib {}

fn main() {
    let mut sc = Scanner::new();

    let n = sc.next_usize();
    let k = sc.next_int();
    let a = sc.next_vec::<i64>(n);

    let mut sum = vec![0; n + 1];
    let mut set = HashSet::new();
    for i in 0..n {
        sum[i + 1] = sum[i] ^ a[i];
    }
    for &vi in &sum {
        set.insert(vi);
    }

    let ans = if sum.iter().any(|j| set.contains(&(j ^ k))) {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}

pub mod basic {
    pub const U_INF: u64 = (1 << 60) + (1 << 30);
    pub const I_INF: i64 = (1 << 60) + (1 << 30);

    pub struct Scanner {
        buf: std::collections::VecDeque<String>,
        reader: std::io::BufReader<std::io::Stdin>,
    }

    impl Scanner {
        pub fn new() -> Self {
            Self {
                buf: std::collections::VecDeque::new(),
                reader: std::io::BufReader::new(std::io::stdin()),
            }
        }

        fn scan_line(&mut self) {
            use std::io::BufRead;
            let mut flag = 0;
            while self.buf.is_empty() {
                let mut s = String::new();
                self.reader.read_line(&mut s).unwrap();
                let mut iter = s.split_whitespace().peekable();
                if iter.peek().is_none() {
                    if flag >= 5 {
                        panic!("There is no input!");
                    }
                    flag += 1;
                    continue;
                }

                for si in iter {
                    self.buf.push_back(si.to_string());
                }
            }
        }

        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            self.scan_line();
            self.buf
                .pop_front()
                .unwrap()
                .parse()
                .unwrap_or_else(|_| panic!("Couldn't parse!"))
        }

        pub fn next_usize(&mut self) -> usize {
            self.next()
        }

        pub fn next_int(&mut self) -> i64 {
            self.next()
        }

        pub fn next_uint(&mut self) -> u64 {
            self.next()
        }

        pub fn next_chars(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_string(&mut self) -> String {
            self.next()
        }

        pub fn next_char(&mut self) -> char {
            self.next()
        }

        pub fn next_float(&mut self) -> f64 {
            self.next()
        }

        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect::<Vec<_>>()
        }
    }
}
0