Submission #245100

# Submission time Handle Problem Language Result Execution time Memory
245100 2020-07-05T13:29:36 Z Tc14 Political Development (BOI17_politicaldevelopment) C++17
4 / 100
160 ms 2040 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ve vector
typedef long long ll;

const int MAXN = 50000;

int r;
ve<int> G[MAXN];
ve<int> S;

bool disagree(int a, int b) {
    for (int i : G[a]) {
        if (i == b) return true;
    }
    return false;
}

void f(int a, int i, int d, int s) {

    bool valid;

    if (i == d) r = max(r, s);
    else {
        f(a, i + 1, d, s);

        valid = true;
        for (int i = 0; i < s; i++) {
            if (!disagree(S[i], G[a][i]) || !disagree(G[a][i], S[i])) {
                valid = false;
                break;
            }
        }

        if (valid) {
            S.push_back(G[a][i]);
            f(a, i + 1, d, s + 1);
            S.pop_back();
        }
    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k, d, a;

    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> a;
            if (a != i) G[i].push_back(a);
        }
    }

    r = 1;
    for (int i = 0; i < n; i++) {
        S = {i};
        f(i, 0, G[i].size(), 1);
    }

    cout << r << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1536 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 7 ms 1792 KB Output is correct
4 Correct 148 ms 2040 KB Output is correct
5 Correct 160 ms 1920 KB Output is correct
6 Correct 17 ms 1792 KB Output is correct
7 Correct 16 ms 1792 KB Output is correct
8 Correct 6 ms 1536 KB Output is correct
9 Correct 6 ms 1536 KB Output is correct
10 Correct 5 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1536 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 7 ms 1792 KB Output is correct
4 Correct 148 ms 2040 KB Output is correct
5 Correct 160 ms 1920 KB Output is correct
6 Correct 17 ms 1792 KB Output is correct
7 Correct 16 ms 1792 KB Output is correct
8 Correct 6 ms 1536 KB Output is correct
9 Correct 6 ms 1536 KB Output is correct
10 Correct 5 ms 1536 KB Output is correct
11 Correct 146 ms 1920 KB Output is correct
12 Correct 147 ms 1920 KB Output is correct
13 Correct 6 ms 1536 KB Output is correct
14 Correct 142 ms 2040 KB Output is correct
15 Correct 5 ms 1536 KB Output is correct
16 Correct 16 ms 1792 KB Output is correct
17 Correct 5 ms 1536 KB Output is correct
18 Correct 16 ms 1664 KB Output is correct
19 Correct 6 ms 1536 KB Output is correct
20 Correct 7 ms 1664 KB Output is correct
21 Correct 7 ms 1664 KB Output is correct
22 Correct 5 ms 1536 KB Output is correct
23 Correct 8 ms 1664 KB Output is correct
24 Correct 5 ms 1536 KB Output is correct
25 Correct 8 ms 1664 KB Output is correct
26 Correct 7 ms 1664 KB Output is correct
27 Correct 7 ms 1664 KB Output is correct
28 Correct 8 ms 1664 KB Output is correct
29 Correct 7 ms 1664 KB Output is correct
30 Correct 46 ms 1792 KB Output is correct
31 Correct 8 ms 1664 KB Output is correct
32 Correct 45 ms 1792 KB Output is correct
33 Correct 8 ms 1712 KB Output is correct
34 Correct 8 ms 1664 KB Output is correct
35 Correct 6 ms 1664 KB Output is correct
36 Correct 6 ms 1536 KB Output is correct
37 Correct 6 ms 1664 KB Output is correct
38 Correct 7 ms 1536 KB Output is correct
39 Correct 6 ms 1536 KB Output is correct
40 Incorrect 10 ms 1664 KB Output isn't correct
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1536 KB Output is correct
2 Incorrect 5 ms 1536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1536 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 7 ms 1792 KB Output is correct
4 Correct 148 ms 2040 KB Output is correct
5 Correct 160 ms 1920 KB Output is correct
6 Correct 17 ms 1792 KB Output is correct
7 Correct 16 ms 1792 KB Output is correct
8 Correct 6 ms 1536 KB Output is correct
9 Correct 6 ms 1536 KB Output is correct
10 Correct 5 ms 1536 KB Output is correct
11 Correct 146 ms 1920 KB Output is correct
12 Correct 147 ms 1920 KB Output is correct
13 Correct 6 ms 1536 KB Output is correct
14 Correct 142 ms 2040 KB Output is correct
15 Correct 5 ms 1536 KB Output is correct
16 Correct 16 ms 1792 KB Output is correct
17 Correct 5 ms 1536 KB Output is correct
18 Correct 16 ms 1664 KB Output is correct
19 Correct 6 ms 1536 KB Output is correct
20 Correct 7 ms 1664 KB Output is correct
21 Correct 7 ms 1664 KB Output is correct
22 Correct 5 ms 1536 KB Output is correct
23 Correct 8 ms 1664 KB Output is correct
24 Correct 5 ms 1536 KB Output is correct
25 Correct 8 ms 1664 KB Output is correct
26 Correct 7 ms 1664 KB Output is correct
27 Correct 7 ms 1664 KB Output is correct
28 Correct 8 ms 1664 KB Output is correct
29 Correct 7 ms 1664 KB Output is correct
30 Correct 46 ms 1792 KB Output is correct
31 Correct 8 ms 1664 KB Output is correct
32 Correct 45 ms 1792 KB Output is correct
33 Correct 8 ms 1712 KB Output is correct
34 Correct 8 ms 1664 KB Output is correct
35 Correct 6 ms 1664 KB Output is correct
36 Correct 6 ms 1536 KB Output is correct
37 Correct 6 ms 1664 KB Output is correct
38 Correct 7 ms 1536 KB Output is correct
39 Correct 6 ms 1536 KB Output is correct
40 Incorrect 10 ms 1664 KB Output isn't correct
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1536 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 7 ms 1792 KB Output is correct
4 Correct 148 ms 2040 KB Output is correct
5 Correct 160 ms 1920 KB Output is correct
6 Correct 17 ms 1792 KB Output is correct
7 Correct 16 ms 1792 KB Output is correct
8 Correct 6 ms 1536 KB Output is correct
9 Correct 6 ms 1536 KB Output is correct
10 Correct 5 ms 1536 KB Output is correct
11 Correct 146 ms 1920 KB Output is correct
12 Correct 147 ms 1920 KB Output is correct
13 Correct 6 ms 1536 KB Output is correct
14 Correct 142 ms 2040 KB Output is correct
15 Correct 5 ms 1536 KB Output is correct
16 Correct 16 ms 1792 KB Output is correct
17 Correct 5 ms 1536 KB Output is correct
18 Correct 16 ms 1664 KB Output is correct
19 Correct 6 ms 1536 KB Output is correct
20 Correct 7 ms 1664 KB Output is correct
21 Correct 7 ms 1664 KB Output is correct
22 Correct 5 ms 1536 KB Output is correct
23 Correct 8 ms 1664 KB Output is correct
24 Correct 5 ms 1536 KB Output is correct
25 Correct 8 ms 1664 KB Output is correct
26 Correct 7 ms 1664 KB Output is correct
27 Correct 7 ms 1664 KB Output is correct
28 Correct 8 ms 1664 KB Output is correct
29 Correct 7 ms 1664 KB Output is correct
30 Correct 46 ms 1792 KB Output is correct
31 Correct 8 ms 1664 KB Output is correct
32 Correct 45 ms 1792 KB Output is correct
33 Correct 8 ms 1712 KB Output is correct
34 Correct 8 ms 1664 KB Output is correct
35 Correct 6 ms 1664 KB Output is correct
36 Correct 6 ms 1536 KB Output is correct
37 Correct 6 ms 1664 KB Output is correct
38 Correct 7 ms 1536 KB Output is correct
39 Correct 6 ms 1536 KB Output is correct
40 Incorrect 10 ms 1664 KB Output isn't correct
41 Halted 0 ms 0 KB -