Submission #47514980


Source Code Expand

use proconio::input;

fn main() {
    input! {
        n: usize,
    }
    let n = 2 * n;
    let a = (0..n)
        .map(|i| {
            input! { a: [u64; n - 1 - i] }
            a
        })
        .collect::<Vec<_>>();
    let mut ans = 0;
    let mut p = (0..n).collect::<Vec<_>>();
    while {
        let mut score = 0;
        for p in p.chunks_exact(2) {
            score ^= a[p[0]][p[1] - p[0] - 1];
        }
        ans = ans.max(score);
        next_pairing(&mut p)
    } {}
    println!("{}", ans);
}

pub fn next_pairing(p: &mut [usize]) -> bool {
    let n = p.len();
    let mut used = 0_u32;
    for i in (0..n).rev() {
        used |= 1 << p[i];
        if i % 2 == 1 && p[i] < used.ilog2() as usize {
            p[i] = (used >> (p[i] + 1)).trailing_zeros() as usize + p[i] + 1;
            used ^= 1 << p[i];
            for i in i + 1..n {
                p[i] = used.trailing_zeros() as usize;
                used ^= 1 << p[i];
            }
            return true;
        }
    }
    false
}

Submission Info

Submission Time
Task D - Dance
User ngtkana
Language Rust (rustc 1.70.0)
Score 400
Code Size 1066 Byte
Status AC
Exec Time 26 ms
Memory 2088 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 28
Set Name Test Cases
Sample example0.txt, example1.txt, example2.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, 024.txt, example0.txt, example1.txt, example2.txt
Case Name Status Exec Time Memory
000.txt AC 1 ms 1996 KiB
001.txt AC 1 ms 1928 KiB
002.txt AC 25 ms 1956 KiB
003.txt AC 25 ms 1912 KiB
004.txt AC 26 ms 1860 KiB
005.txt AC 1 ms 2068 KiB
006.txt AC 1 ms 1928 KiB
007.txt AC 1 ms 1852 KiB
008.txt AC 1 ms 1900 KiB
009.txt AC 2 ms 1928 KiB
010.txt AC 1 ms 2068 KiB
011.txt AC 2 ms 1912 KiB
012.txt AC 1 ms 1980 KiB
013.txt AC 0 ms 1920 KiB
014.txt AC 1 ms 2068 KiB
015.txt AC 26 ms 1924 KiB
016.txt AC 25 ms 1860 KiB
017.txt AC 25 ms 1932 KiB
018.txt AC 25 ms 1868 KiB
019.txt AC 25 ms 1944 KiB
020.txt AC 25 ms 1936 KiB
021.txt AC 26 ms 2088 KiB
022.txt AC 25 ms 1796 KiB
023.txt AC 26 ms 1968 KiB
024.txt AC 26 ms 2004 KiB
example0.txt AC 1 ms 1904 KiB
example1.txt AC 1 ms 1876 KiB
example2.txt AC 0 ms 1908 KiB