Submission #2012541
Source Code Expand
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
mod util {
use std::io::stdin;
use std::str::FromStr;
use std::fmt::Debug;
#[allow(dead_code)]
pub fn line() -> String {
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.trim().to_string()
}
#[allow(dead_code)]
pub fn gets<T: FromStr>() -> Vec<T>
where
<T as FromStr>::Err: Debug,
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.split_whitespace()
.map(|t| t.parse().unwrap())
.collect()
}
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; 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 ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
fn main() {
let n = get!(usize);
let aa = get!(u64; n);
let mut xor = aa.iter().fold(0, |a, &b| a ^ b);
let nums = aa.iter()
.map(|a| a.trailing_zeros())
.collect::<HashSet<_>>();
let mut ans = 0;
while xor != 0 {
ans += 1;
let i = 64 - xor.leading_zeros();
if !nums.contains(&(i - 1)) {
println!("{}", -1);
return;
}
xor = (!xor) & ((1 << i) - 1);
}
println!("{}", ans);
}
Submission Info
Submission Time |
|
Task |
C - Cheating Nim |
User |
hatoo |
Language |
Rust (1.15.1) |
Score |
500 |
Code Size |
2531 Byte |
Status |
AC |
Exec Time |
18 ms |
Memory |
6396 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example0.txt, example1.txt |
All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt |
Case Name |
Status |
Exec Time |
Memory |
000.txt |
AC |
2 ms |
4352 KB |
001.txt |
AC |
2 ms |
4352 KB |
002.txt |
AC |
17 ms |
6396 KB |
003.txt |
AC |
10 ms |
6396 KB |
004.txt |
AC |
8 ms |
4352 KB |
005.txt |
AC |
6 ms |
4352 KB |
006.txt |
AC |
17 ms |
6396 KB |
007.txt |
AC |
17 ms |
6396 KB |
008.txt |
AC |
17 ms |
6396 KB |
009.txt |
AC |
17 ms |
6396 KB |
010.txt |
AC |
17 ms |
6396 KB |
011.txt |
AC |
17 ms |
6396 KB |
012.txt |
AC |
17 ms |
6396 KB |
013.txt |
AC |
17 ms |
6396 KB |
014.txt |
AC |
17 ms |
6396 KB |
015.txt |
AC |
17 ms |
6396 KB |
016.txt |
AC |
18 ms |
6396 KB |
017.txt |
AC |
17 ms |
6396 KB |
018.txt |
AC |
17 ms |
6396 KB |
019.txt |
AC |
17 ms |
6396 KB |
020.txt |
AC |
17 ms |
6396 KB |
021.txt |
AC |
3 ms |
4352 KB |
022.txt |
AC |
3 ms |
4352 KB |
023.txt |
AC |
17 ms |
6396 KB |
example0.txt |
AC |
2 ms |
4352 KB |
example1.txt |
AC |
2 ms |
4352 KB |