結果

問題 No.2672 Subset Xor Sum
ユーザー sakikuroe
提出日時 2024-03-15 21:55:52
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 1,024 bytes
コンパイル時間 12,338 ms
コンパイル使用メモリ 396,416 KB
実行使用メモリ 14,500 KB
最終ジャッジ日時 2024-09-30 01:02:12
合計ジャッジ時間 17,318 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27 WA * 2 TLE * 1 -- * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let n;
    {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut ws = s.split_whitespace();
        n = ws.next().unwrap().parse::<usize>().unwrap();
    }

    let a;
    {
        let mut res: Vec<_> = vec![];
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut ws = s.split_whitespace();
        for _ in 0..n {
            res.push(ws.next().unwrap().parse::<usize>().unwrap());
        }
        a = res;
    }

    if a.iter().cloned().fold(0_usize, |x, y| x ^ y) != 0 {
        println!("No");
        return;
    }

    let mut dp = Vec::new();
    dp.resize(20000, 0);

    for i in 0..n {
        let mut temp = dp.clone();
        temp.resize(20000, 0);
        temp[a[i]] += 1;
        for j in 0..20000 {
            if j ^ a[i] < 20000 {
                temp[j ^ a[i]] += dp[j];
            }
        }
        dp = temp;
    }

    println!("{}", if dp[0] >= 2 { "Yes" } else { "No" });
}
0