結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー | xoke0114 |
提出日時 | 2018-03-21 12:45:42 |
言語 | Rust (1.77.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 5,024 bytes |
コンパイル時間 | 15,389 ms |
コンパイル使用メモリ | 379,032 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-06-24 19:28:40 |
合計ジャッジ時間 | 26,855 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
7,168 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 6 ms
5,376 KB |
testcase_03 | AC | 5 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 7 ms
5,376 KB |
testcase_06 | AC | 3 ms
5,376 KB |
testcase_07 | AC | 4,909 ms
5,376 KB |
testcase_08 | TLE | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
#![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 { for i in 0..32770 { let mut okay = false; for j in 0..k { let idx = i ^ v[j]; if idx >= 32770 { continue; } if dp[i] | dp[idx] { okay = true; break; } } if okay { dp[i] = true; if k == N { ans += 1; } } } } pr.println(ans); }