Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Created by Mahmoud Rashad on 11/27/19.
- //
- #include <bits/stdc++.h>
- using namespace std;
- typedef vector<pair<int, bool>> vii;
- int main(){
- int n;
- cin >> n;
- vector<vii> data(n, vii());
- for (int i = 0; i < n; ++i) {
- int a;
- cin >> a;
- while (a--) {
- int u;
- bool kind;
- cin >> u >> kind;
- data[i].push_back({--u, kind});
- }
- }
- int ans = 0;
- for(int mask = 0; mask < (1 << n); ++mask) {
- bool f = true;
- for (int i = 0; i < n; ++i) {
- if (!(mask & (1 << i)))
- continue;
- for (auto &p : data[i]) {
- int u = p.first;
- bool kind = p.second;
- // cout << mask << ' ' << u << ' ' << kind << endl;
- f &= ((bool)(mask & (1 << u)) == kind);
- }
- }
- // cout << mask << ' ' << f << endl;
- ans = max(ans, __builtin_popcount(mask) * f);
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement