답안 #445716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445716 2021-07-19T10:52:52 Z prvocislo Political Development (BOI17_politicaldevelopment) C++17
100 / 100
492 ms 28760 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<set<int> > g(n);
    set<pair<int, int> > pq;
    for (int u = 0, d; u < n; u++)
    {
        cin >> d;
        for (int j = 0, v; j < d; j++) cin >> v, g[u].insert(v);
        pq.insert({d, u});
    }
    int ans = 1;
    while (!pq.empty())
    {
        int u = pq.begin()->second;
        pq.erase(pq.begin());
        vector<int> c = {u};
        for (int v : g[u]) c.push_back(v);
        vector<int> g2(c.size(), 0);
        for (int i = 0; i < c.size(); i++) for (int j = 0; j < c.size(); j++)
            if (g[c[i]].count(c[j])) g2[i] |= (1 << j);
        for (int i = 1; i < (1 << c.size()); i += 2) // prvy bit musime mat
        {
            int cnt = __builtin_popcount(i);
            if (cnt <= ans) continue;
            bool ok = true;
            for (int u = 1; u < c.size(); u++)
            {
                if (!(i & (1<<u))) continue;
                for (int v = u+1; v < c.size(); v++)
                {
                    if (!(i & (1<<v))) continue;
                    if (!(g2[u] & (1<<v)))
                    {
                        ok = false;
                        break;
                    } 
                } 
                if (!ok) break;
            }
            if (ok) ans = max(ans, cnt);
        }
        for (int v : g[u])
        {
            pq.erase({g[v].size(), v});
            g[v].erase(u);
            pq.insert({g[v].size(), v});
        }
    }
    cout << ans << "\n";
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:26:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for (int i = 0; i < c.size(); i++) for (int j = 0; j < c.size(); j++)
      |                         ~~^~~~~~~~~~
politicaldevelopment.cpp:26:62: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for (int i = 0; i < c.size(); i++) for (int j = 0; j < c.size(); j++)
      |                                                            ~~^~~~~~~~~~
politicaldevelopment.cpp:33:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             for (int u = 1; u < c.size(); u++)
      |                             ~~^~~~~~~~~~
politicaldevelopment.cpp:36:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |                 for (int v = u+1; v < c.size(); v++)
      |                                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 7 ms 1248 KB Output is correct
4 Correct 6 ms 1228 KB Output is correct
5 Correct 6 ms 1228 KB Output is correct
6 Correct 8 ms 1224 KB Output is correct
7 Correct 7 ms 1228 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 7 ms 1248 KB Output is correct
4 Correct 6 ms 1228 KB Output is correct
5 Correct 6 ms 1228 KB Output is correct
6 Correct 8 ms 1224 KB Output is correct
7 Correct 7 ms 1228 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 6 ms 1228 KB Output is correct
12 Correct 6 ms 1228 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 6 ms 1228 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 6 ms 1228 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 7 ms 1228 KB Output is correct
19 Correct 2 ms 716 KB Output is correct
20 Correct 4 ms 972 KB Output is correct
21 Correct 5 ms 972 KB Output is correct
22 Correct 2 ms 716 KB Output is correct
23 Correct 8 ms 1356 KB Output is correct
24 Correct 2 ms 716 KB Output is correct
25 Correct 8 ms 1356 KB Output is correct
26 Correct 7 ms 1356 KB Output is correct
27 Correct 6 ms 1228 KB Output is correct
28 Correct 8 ms 1356 KB Output is correct
29 Correct 6 ms 1228 KB Output is correct
30 Correct 8 ms 1484 KB Output is correct
31 Correct 8 ms 1484 KB Output is correct
32 Correct 9 ms 1480 KB Output is correct
33 Correct 8 ms 1484 KB Output is correct
34 Correct 11 ms 1476 KB Output is correct
35 Correct 6 ms 892 KB Output is correct
36 Correct 4 ms 844 KB Output is correct
37 Correct 4 ms 844 KB Output is correct
38 Correct 3 ms 588 KB Output is correct
39 Correct 3 ms 588 KB Output is correct
40 Correct 13 ms 1740 KB Output is correct
41 Correct 3 ms 588 KB Output is correct
42 Correct 13 ms 1752 KB Output is correct
43 Correct 12 ms 1740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 716 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 464 ms 28732 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 462 ms 28660 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 448 ms 28740 KB Output is correct
16 Correct 492 ms 28760 KB Output is correct
17 Correct 457 ms 28688 KB Output is correct
18 Correct 478 ms 28684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 7 ms 1248 KB Output is correct
4 Correct 6 ms 1228 KB Output is correct
5 Correct 6 ms 1228 KB Output is correct
6 Correct 8 ms 1224 KB Output is correct
7 Correct 7 ms 1228 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 6 ms 1228 KB Output is correct
12 Correct 6 ms 1228 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 6 ms 1228 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 6 ms 1228 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 7 ms 1228 KB Output is correct
19 Correct 2 ms 716 KB Output is correct
20 Correct 4 ms 972 KB Output is correct
21 Correct 5 ms 972 KB Output is correct
22 Correct 2 ms 716 KB Output is correct
23 Correct 8 ms 1356 KB Output is correct
24 Correct 2 ms 716 KB Output is correct
25 Correct 8 ms 1356 KB Output is correct
26 Correct 7 ms 1356 KB Output is correct
27 Correct 6 ms 1228 KB Output is correct
28 Correct 8 ms 1356 KB Output is correct
29 Correct 6 ms 1228 KB Output is correct
30 Correct 8 ms 1484 KB Output is correct
31 Correct 8 ms 1484 KB Output is correct
32 Correct 9 ms 1480 KB Output is correct
33 Correct 8 ms 1484 KB Output is correct
34 Correct 11 ms 1476 KB Output is correct
35 Correct 6 ms 892 KB Output is correct
36 Correct 4 ms 844 KB Output is correct
37 Correct 4 ms 844 KB Output is correct
38 Correct 3 ms 588 KB Output is correct
39 Correct 3 ms 588 KB Output is correct
40 Correct 13 ms 1740 KB Output is correct
41 Correct 3 ms 588 KB Output is correct
42 Correct 13 ms 1752 KB Output is correct
43 Correct 12 ms 1740 KB Output is correct
44 Correct 23 ms 2764 KB Output is correct
45 Correct 1 ms 308 KB Output is correct
46 Correct 12 ms 1724 KB Output is correct
47 Correct 25 ms 2800 KB Output is correct
48 Correct 13 ms 1740 KB Output is correct
49 Correct 26 ms 2852 KB Output is correct
50 Correct 27 ms 2764 KB Output is correct
51 Correct 68 ms 4820 KB Output is correct
52 Correct 6 ms 1228 KB Output is correct
53 Correct 74 ms 5412 KB Output is correct
54 Correct 87 ms 5440 KB Output is correct
55 Correct 7 ms 1228 KB Output is correct
56 Correct 9 ms 1272 KB Output is correct
57 Correct 2 ms 716 KB Output is correct
58 Correct 93 ms 5312 KB Output is correct
59 Correct 13 ms 1740 KB Output is correct
60 Correct 7 ms 1228 KB Output is correct
61 Correct 10 ms 1740 KB Output is correct
62 Correct 10 ms 1740 KB Output is correct
63 Correct 21 ms 2820 KB Output is correct
64 Correct 17 ms 2508 KB Output is correct
65 Correct 11 ms 1608 KB Output is correct
66 Correct 9 ms 1740 KB Output is correct
67 Correct 34 ms 3224 KB Output is correct
68 Correct 17 ms 2508 KB Output is correct
69 Correct 20 ms 1612 KB Output is correct
70 Correct 30 ms 2636 KB Output is correct
71 Correct 32 ms 3216 KB Output is correct
72 Correct 30 ms 3172 KB Output is correct
73 Correct 8 ms 1228 KB Output is correct
74 Correct 23 ms 2636 KB Output is correct
75 Correct 32 ms 3144 KB Output is correct
76 Correct 18 ms 2116 KB Output is correct
77 Correct 47 ms 3660 KB Output is correct
78 Correct 7 ms 1228 KB Output is correct
79 Correct 22 ms 1996 KB Output is correct
80 Correct 18 ms 2068 KB Output is correct
81 Correct 49 ms 3656 KB Output is correct
82 Correct 3 ms 588 KB Output is correct
83 Correct 22 ms 1984 KB Output is correct
84 Correct 32 ms 3148 KB Output is correct
85 Correct 3 ms 580 KB Output is correct
86 Correct 32 ms 3008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 7 ms 1248 KB Output is correct
4 Correct 6 ms 1228 KB Output is correct
5 Correct 6 ms 1228 KB Output is correct
6 Correct 8 ms 1224 KB Output is correct
7 Correct 7 ms 1228 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 6 ms 1228 KB Output is correct
12 Correct 6 ms 1228 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 6 ms 1228 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 6 ms 1228 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 7 ms 1228 KB Output is correct
19 Correct 2 ms 716 KB Output is correct
20 Correct 4 ms 972 KB Output is correct
21 Correct 5 ms 972 KB Output is correct
22 Correct 2 ms 716 KB Output is correct
23 Correct 8 ms 1356 KB Output is correct
24 Correct 2 ms 716 KB Output is correct
25 Correct 8 ms 1356 KB Output is correct
26 Correct 7 ms 1356 KB Output is correct
27 Correct 6 ms 1228 KB Output is correct
28 Correct 8 ms 1356 KB Output is correct
29 Correct 6 ms 1228 KB Output is correct
30 Correct 8 ms 1484 KB Output is correct
31 Correct 8 ms 1484 KB Output is correct
32 Correct 9 ms 1480 KB Output is correct
33 Correct 8 ms 1484 KB Output is correct
34 Correct 11 ms 1476 KB Output is correct
35 Correct 6 ms 892 KB Output is correct
36 Correct 4 ms 844 KB Output is correct
37 Correct 4 ms 844 KB Output is correct
38 Correct 3 ms 588 KB Output is correct
39 Correct 3 ms 588 KB Output is correct
40 Correct 13 ms 1740 KB Output is correct
41 Correct 3 ms 588 KB Output is correct
42 Correct 13 ms 1752 KB Output is correct
43 Correct 12 ms 1740 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 306 ms 20880 KB Output is correct
46 Correct 130 ms 12864 KB Output is correct
47 Correct 316 ms 20868 KB Output is correct
48 Correct 291 ms 20792 KB Output is correct
49 Correct 76 ms 10308 KB Output is correct
50 Correct 275 ms 26040 KB Output is correct
51 Correct 292 ms 20744 KB Output is correct
52 Correct 76 ms 10344 KB Output is correct
53 Correct 75 ms 10272 KB Output is correct
54 Correct 20 ms 5016 KB Output is correct
55 Correct 304 ms 26076 KB Output is correct
56 Correct 45 ms 7608 KB Output is correct
57 Correct 72 ms 10280 KB Output is correct
58 Correct 90 ms 12896 KB Output is correct
59 Correct 46 ms 7752 KB Output is correct
60 Correct 51 ms 7620 KB Output is correct
61 Correct 92 ms 12960 KB Output is correct
62 Correct 64 ms 10240 KB Output is correct
63 Correct 164 ms 14276 KB Output is correct
64 Correct 44 ms 7724 KB Output is correct
65 Correct 193 ms 16908 KB Output is correct
66 Correct 65 ms 10304 KB Output is correct
67 Correct 162 ms 14196 KB Output is correct
68 Correct 193 ms 16248 KB Output is correct
69 Correct 202 ms 16904 KB Output is correct
70 Correct 78 ms 10296 KB Output is correct
71 Correct 205 ms 16260 KB Output is correct
72 Correct 143 ms 13768 KB Output is correct
73 Correct 233 ms 18584 KB Output is correct
74 Correct 77 ms 10304 KB Output is correct
75 Correct 89 ms 7796 KB Output is correct
76 Correct 135 ms 13808 KB Output is correct
77 Correct 294 ms 18620 KB Output is correct
78 Correct 97 ms 9436 KB Output is correct
79 Correct 77 ms 7756 KB Output is correct
80 Correct 30 ms 4036 KB Output is correct
81 Correct 94 ms 9368 KB Output is correct
82 Correct 179 ms 15592 KB Output is correct
83 Correct 40 ms 3960 KB Output is correct
84 Correct 156 ms 15536 KB Output is correct