Submission #62199108


Source Code Expand

use std::collections::BTreeSet;
use itertools::Itertools;
use proconio::input;

fn dfs(v: &mut Vec<u64>, i: usize, a: &Vec<u64>, ans: &mut Vec<u64>) {
    if i == a.len() {
        ans.push(v.iter().fold(0, |acc, &x| acc ^ x));
        return;
    }

    for j in 0..v.len() {
        v[j] += a[i];
        dfs(v, i + 1, a, ans);
        v[j] -= a[i];
    }
    v.push(a[i]);
    dfs(v, i + 1, a, ans);
    v.pop();
}

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let mut ans = Vec::new();
    dfs(&mut Vec::new(), 0, &a, &mut ans);
    println!("{}", ans.iter().sorted_unstable().dedup().count());
}

Submission Info

Submission Time
Task D - Stone XOR
User ardRiriy
Language Rust (rustc 1.70.0)
Score 400
Code Size 631 Byte
Status AC
Exec Time 369 ms
Memory 67808 KiB

Compile Error

warning: unused import: `std::collections::BTreeSet`
 --> src/main.rs:1:5
  |
1 | use std::collections::BTreeSet;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 39
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 1944 KiB
example_01.txt AC 1 ms 1956 KiB
example_02.txt AC 1 ms 1876 KiB
hand_00.txt AC 134 ms 67772 KiB
hand_01.txt AC 198 ms 67632 KiB
hand_02.txt AC 71 ms 67808 KiB
hand_03.txt AC 299 ms 67688 KiB
hand_04.txt AC 1 ms 1936 KiB
hand_05.txt AC 173 ms 67708 KiB
random_00.txt AC 6 ms 3552 KiB
random_01.txt AC 1 ms 1960 KiB
random_02.txt AC 1 ms 2084 KiB
random_03.txt AC 1 ms 1952 KiB
random_04.txt AC 332 ms 67800 KiB
random_05.txt AC 141 ms 67708 KiB
random_06.txt AC 3 ms 3432 KiB
random_07.txt AC 1 ms 1880 KiB
random_08.txt AC 158 ms 67748 KiB
random_09.txt AC 3 ms 3432 KiB
random_10.txt AC 201 ms 67692 KiB
random_11.txt AC 4 ms 3652 KiB
random_12.txt AC 5 ms 3548 KiB
random_13.txt AC 282 ms 67788 KiB
random_14.txt AC 27 ms 12496 KiB
random_15.txt AC 369 ms 67780 KiB
random_16.txt AC 350 ms 67712 KiB
random_17.txt AC 6 ms 3596 KiB
random_18.txt AC 6 ms 3504 KiB
random_19.txt AC 1 ms 2084 KiB
random_20.txt AC 1 ms 1816 KiB
random_21.txt AC 274 ms 67744 KiB
random_22.txt AC 6 ms 3580 KiB
random_23.txt AC 1 ms 1852 KiB
random_24.txt AC 31 ms 12416 KiB
random_25.txt AC 3 ms 3580 KiB
random_26.txt AC 1 ms 1932 KiB
random_27.txt AC 17 ms 12436 KiB
random_28.txt AC 3 ms 3484 KiB
random_29.txt AC 121 ms 67740 KiB