답안 #248881

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
248881 2020-07-13T16:30:37 Z Tc14 Political Development (BOI17_politicaldevelopment) C++17
39 / 100
164 ms 27760 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ve vector
typedef long long ll;

int ans;
ve<int> S, T;
ve<set<int>> G;

void f(int i, int s) {

    bool valid;

    if (i < S.size()) {

        f(i + 1, s);

        valid = true;
        for (int t : T) {
            if (G[t].find(S[i]) == G[t].end()) {
                valid = false;
                break;
            }
        }

        if (valid) {
            T.push_back(S[i]);
            f(i + 1, s + 1);
            T.pop_back();
        }
    }
    else ans = max(ans, s);

}

int main() {

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

    int n, k, d, a, u;
    ve<int> D;
    queue<int> Q;

    cin >> n >> k;
    G = ve<set<int>>(n);
    D = ve<int>(n);

    for (int i = 0; i < n; i++) {
        cin >> d;
        D[i] = d;
        for (int j = 0; j < d; j++) {
            cin >> a;
            G[i].insert(a);
        }
        if (d < k) Q.push(i);
    }

    ans = 0;
    for (int i = 0; i < n; i++) {
        u = Q.front();
        Q.pop();
        D[u] = 0;
        S.clear();
        for (int v : G[u]) {
            if (D[v] > 0) {
                D[v]--;
                S.push_back(v);
                if (D[v] < k) Q.push(v);
            }
        }
        f(0, 1);
    }

    cout << ans << endl;

    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'void f(int, int)':
politicaldevelopment.cpp:15:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (i < S.size()) {
         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 3 ms 1152 KB Output is correct
4 Correct 3 ms 1152 KB Output is correct
5 Correct 4 ms 1144 KB Output is correct
6 Correct 3 ms 1152 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 3 ms 1152 KB Output is correct
4 Correct 3 ms 1152 KB Output is correct
5 Correct 4 ms 1144 KB Output is correct
6 Correct 3 ms 1152 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
11 Correct 3 ms 1152 KB Output is correct
12 Correct 4 ms 1152 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 4 ms 1152 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 3 ms 1152 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 3 ms 1152 KB Output is correct
19 Correct 1 ms 640 KB Output is correct
20 Correct 2 ms 896 KB Output is correct
21 Correct 2 ms 896 KB Output is correct
22 Correct 1 ms 640 KB Output is correct
23 Correct 4 ms 1280 KB Output is correct
24 Correct 1 ms 640 KB Output is correct
25 Correct 4 ms 1280 KB Output is correct
26 Correct 4 ms 1280 KB Output is correct
27 Correct 3 ms 1152 KB Output is correct
28 Correct 3 ms 1152 KB Output is correct
29 Correct 3 ms 1152 KB Output is correct
30 Correct 4 ms 1280 KB Output is correct
31 Correct 4 ms 1280 KB Output is correct
32 Correct 4 ms 1280 KB Output is correct
33 Correct 4 ms 1280 KB Output is correct
34 Correct 4 ms 1280 KB Output is correct
35 Correct 3 ms 936 KB Output is correct
36 Correct 2 ms 768 KB Output is correct
37 Correct 2 ms 768 KB Output is correct
38 Correct 2 ms 640 KB Output is correct
39 Correct 2 ms 640 KB Output is correct
40 Correct 5 ms 1664 KB Output is correct
41 Correct 2 ms 640 KB Output is correct
42 Correct 6 ms 1664 KB Output is correct
43 Correct 5 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 160 ms 27640 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 160 ms 27640 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 158 ms 27760 KB Output is correct
16 Correct 164 ms 27640 KB Output is correct
17 Correct 157 ms 27640 KB Output is correct
18 Correct 162 ms 27640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 3 ms 1152 KB Output is correct
4 Correct 3 ms 1152 KB Output is correct
5 Correct 4 ms 1144 KB Output is correct
6 Correct 3 ms 1152 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
11 Correct 3 ms 1152 KB Output is correct
12 Correct 4 ms 1152 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 4 ms 1152 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 3 ms 1152 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 3 ms 1152 KB Output is correct
19 Correct 1 ms 640 KB Output is correct
20 Correct 2 ms 896 KB Output is correct
21 Correct 2 ms 896 KB Output is correct
22 Correct 1 ms 640 KB Output is correct
23 Correct 4 ms 1280 KB Output is correct
24 Correct 1 ms 640 KB Output is correct
25 Correct 4 ms 1280 KB Output is correct
26 Correct 4 ms 1280 KB Output is correct
27 Correct 3 ms 1152 KB Output is correct
28 Correct 3 ms 1152 KB Output is correct
29 Correct 3 ms 1152 KB Output is correct
30 Correct 4 ms 1280 KB Output is correct
31 Correct 4 ms 1280 KB Output is correct
32 Correct 4 ms 1280 KB Output is correct
33 Correct 4 ms 1280 KB Output is correct
34 Correct 4 ms 1280 KB Output is correct
35 Correct 3 ms 936 KB Output is correct
36 Correct 2 ms 768 KB Output is correct
37 Correct 2 ms 768 KB Output is correct
38 Correct 2 ms 640 KB Output is correct
39 Correct 2 ms 640 KB Output is correct
40 Correct 5 ms 1664 KB Output is correct
41 Correct 2 ms 640 KB Output is correct
42 Correct 6 ms 1664 KB Output is correct
43 Correct 5 ms 1664 KB Output is correct
44 Correct 19 ms 2816 KB Output is correct
45 Correct 0 ms 384 KB Output is correct
46 Incorrect 6 ms 1724 KB Output isn't correct
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 3 ms 1152 KB Output is correct
4 Correct 3 ms 1152 KB Output is correct
5 Correct 4 ms 1144 KB Output is correct
6 Correct 3 ms 1152 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
11 Correct 3 ms 1152 KB Output is correct
12 Correct 4 ms 1152 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 4 ms 1152 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 3 ms 1152 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 3 ms 1152 KB Output is correct
19 Correct 1 ms 640 KB Output is correct
20 Correct 2 ms 896 KB Output is correct
21 Correct 2 ms 896 KB Output is correct
22 Correct 1 ms 640 KB Output is correct
23 Correct 4 ms 1280 KB Output is correct
24 Correct 1 ms 640 KB Output is correct
25 Correct 4 ms 1280 KB Output is correct
26 Correct 4 ms 1280 KB Output is correct
27 Correct 3 ms 1152 KB Output is correct
28 Correct 3 ms 1152 KB Output is correct
29 Correct 3 ms 1152 KB Output is correct
30 Correct 4 ms 1280 KB Output is correct
31 Correct 4 ms 1280 KB Output is correct
32 Correct 4 ms 1280 KB Output is correct
33 Correct 4 ms 1280 KB Output is correct
34 Correct 4 ms 1280 KB Output is correct
35 Correct 3 ms 936 KB Output is correct
36 Correct 2 ms 768 KB Output is correct
37 Correct 2 ms 768 KB Output is correct
38 Correct 2 ms 640 KB Output is correct
39 Correct 2 ms 640 KB Output is correct
40 Correct 5 ms 1664 KB Output is correct
41 Correct 2 ms 640 KB Output is correct
42 Correct 6 ms 1664 KB Output is correct
43 Correct 5 ms 1664 KB Output is correct
44 Correct 0 ms 384 KB Output is correct
45 Correct 102 ms 18936 KB Output is correct
46 Correct 48 ms 11128 KB Output is correct
47 Incorrect 105 ms 19068 KB Output isn't correct
48 Halted 0 ms 0 KB -