Skip to content

Commit

Permalink
past15-open g
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Dec 11, 2023
1 parent adce903 commit 937f395
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions cargo-atcoder-1.70.0/contests/past15-open/src/bin/g.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,26 @@ use proconio::{input, marker::Usize1};
fn main() {
input! {
n: usize,
a: [Usize1; n],
m: usize,
};
let ans = n - a.len();
println!("{}", ans);
let mut abs = vec![];
for _ in 0..m {
input! {
k: usize,
ab: [(Usize1, usize); k],
}
abs.push(ab);
}

for bits in 0..1 << n {
let x = (0..n).map(|i| (bits >> i) & 1).collect::<Vec<usize>>();
if abs
.iter()
.all(|ab| ab.iter().copied().any(|(a, b)| x[a] == b))
{
println!("Yes");
return;
}
}
println!("No");
}

0 comments on commit 937f395

Please sign in to comment.