結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー | xoke0114 |
提出日時 | 2018-03-21 12:59:03 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 155 ms / 5,000 ms |
コード長 | 4,878 bytes |
コンパイル時間 | 14,459 ms |
コンパイル使用メモリ | 404,548 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 04:59:28 |
合計ジャッジ時間 | 16,707 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 155 ms
6,944 KB |
testcase_08 | AC | 117 ms
6,944 KB |
testcase_09 | AC | 80 ms
6,940 KB |
testcase_10 | AC | 96 ms
6,944 KB |
testcase_11 | AC | 129 ms
6,944 KB |
testcase_12 | AC | 1 ms
6,944 KB |
testcase_13 | AC | 1 ms
6,944 KB |
testcase_14 | AC | 62 ms
6,940 KB |
testcase_15 | AC | 134 ms
6,940 KB |
testcase_16 | AC | 1 ms
6,940 KB |
testcase_17 | AC | 30 ms
6,940 KB |
testcase_18 | AC | 137 ms
6,944 KB |
testcase_19 | AC | 15 ms
6,944 KB |
ソースコード
#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)] use std::io::{stdin, Read, StdinLock}; use std::str::FromStr; use std::fmt::*; use std::str::*; use std::cmp::*; use std::collections::*; fn getline() -> String { let mut res = String::new(); std::io::stdin().read_line(&mut res).ok(); res } macro_rules ! readl { ( $ t : ty ) => { { let s = getline ( ) ; s . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,+ ) => { { let s = getline ( ) ; let mut iter = s . trim ( ) . split ( ' ' ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; } macro_rules ! readlvec { ( $ t : ty ) => { { let s = getline ( ) ; let iter = s . trim ( ) . split ( ' ' ) ; iter . map ( | x | x . parse ( ) . unwrap ( ) ) . collect ::< Vec <$ t >> ( ) } } } macro_rules ! mvec { ( $ v : expr , $ s : expr ) => { vec ! [ $ v ; $ s ] } ; ( $ v : expr , $ s : expr , $ ( $ t : expr ) ,* ) => { vec ! [ mvec ! ( $ v , $ ( $ t ) ,* ) ; $ s ] } ; } macro_rules ! debug { ( $ x : expr ) => { println ! ( "{}: {:?}" , stringify ! ( $ x ) , $ x ) } } fn printiter<'a, T>(v: &'a T) where &'a T: std::iter::IntoIterator, <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display, { for (i, e) in v.into_iter().enumerate() { if i != 0 { print!(" "); } print!("{}", e); } println!(""); } struct ContestPrinter { s: String, } impl ContestPrinter { fn new() -> ContestPrinter { ContestPrinter { s: String::new() } } fn print<T>(&mut self, x: T) where T: std::fmt::Display, { self.s.push_str(format!("{}", x).as_str()); } fn println<T>(&mut self, x: T) where T: std::fmt::Display, { self.s.push_str(format!("{}\n", x).as_str()); } } impl std::ops::Drop for ContestPrinter { fn drop(&mut self) { print!("{}", self.s); } } fn is_max_i64(num: i64) -> bool { if num == i64::max_value() { true } else { false } } macro_rules! get { ($t:ty) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($($t:ty),*) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; ($t:ty; $n:expr) => { (0..$n).map(|_| get!($t) ).collect::<Vec<_>>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| get!($($t),*) ).collect::<Vec<_>>() }; ($t:ty ;;) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::<Vec<_>>() } }; ($t:ty ;; $n:expr) => { (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>() }; } pub trait InputValue { fn parse(s: &str) -> Self; } pub fn read<T: InputValue>() -> T { let mut buf = String::new(); let _ = stdin().read_line(&mut buf); T::parse(&buf.trim()) } pub fn readnc<T: InputValue>() -> Vec<T> { let mut vec = vec![]; let line: String = read(); for token in line.split_whitespace() { vec.push(T::parse(token)); } vec } pub fn readn<T: InputValue>(n: usize) -> Vec<T> { let mut vec = vec![]; for _ in 0..n { vec.push(read()); } vec } macro_rules! parse_single_value { ($($t:ty),*) => { $( impl InputValue for $t { fn parse(s: &str) -> $t { s.parse().unwrap() } } )* } } parse_single_value!(i32, i64, f32, f64, usize, String); macro_rules! parse_tuple { ($($t:ident),*) => { impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* { fn parse(s: &str) -> ($($t),*) { let mut tokens = s.split_whitespace(); let t = ($($t::parse(tokens.next().unwrap())),*); t } } } } parse_tuple!(A, B); parse_tuple!(A, B, C); fn main() { let mut pr = ContestPrinter::new(); let N: usize = read(); let v: Vec<usize> = readnc(); let mut dp = vec![false; 32770]; dp[0] = true; let mut ans = 0; for k in 1..N+1 { let a = v[k-1]; for i in 0..32770 { if dp[i] { let idx = i ^ a; if idx >= 32770 { continue; } dp[idx] = true; } } } for i in 0..32770 { if dp[i] { ans += 1; } } pr.println(ans); }