結果
問題 | No.2672 Subset Xor Sum |
ユーザー |
|
提出日時 | 2024-03-15 22:08:47 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1,939 ms / 2,000 ms |
コード長 | 1,035 bytes |
コンパイル時間 | 10,451 ms |
コンパイル使用メモリ | 393,296 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-09-30 01:25:04 |
合計ジャッジ時間 | 25,077 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 66 |
ソースコード
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![0_u8; 5001]; for i in 0..n { let mut temp = dp.clone(); for j in 0..5000 + 1 { if j ^ a[i] < 5000 + 1 { temp[j ^ a[i]] = temp[j ^ a[i]].saturating_add(dp[j]); } } temp[a[i]] += 1; std::mem::swap(&mut dp, &mut temp); } println!("{}", if dp[0] >= 2 { "Yes" } else { "No" }); }