Submission #8830089


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Submission Info

Submission Time
Task C - HonestOrUnkind2
User kort0n
Language C++14 (GCC 5.4.1)
Score 300
Code Size 851 Byte
Status AC
Exec Time 7 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample00, sample01, sample02
All handmade03, handmade04, handmade05, handmade06, handmade07, handmade08, random09, random10, random11, random12, random13, random14, sample00, sample01, sample02
Case Name Status Exec Time Memory
handmade03 AC 7 ms 256 KB
handmade04 AC 7 ms 256 KB
handmade05 AC 4 ms 256 KB
handmade06 AC 7 ms 256 KB
handmade07 AC 7 ms 256 KB
handmade08 AC 1 ms 256 KB
random09 AC 3 ms 256 KB
random10 AC 4 ms 256 KB
random11 AC 2 ms 256 KB
random12 AC 5 ms 256 KB
random13 AC 5 ms 256 KB
random14 AC 5 ms 256 KB
sample00 AC 1 ms 256 KB
sample01 AC 1 ms 256 KB
sample02 AC 1 ms 256 KB