답안 #520694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
520694 2022-01-30T20:47:58 Z Yazan_Alattar Political Development (BOI17_politicaldevelopment) C++14
100 / 100
1681 ms 42640 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <utility>
#include <cmath>
#include <numeric>
#include <assert.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 200007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

queue <int> q;
vector <int> adj[M];
set <int> edge[M];
int n, k, sz[M], ans;
bool vist[M];

bool cmp(int x, int y) { return adj[x].size() < adj[y].size(); }

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; ++i){
        int m;
        cin >> m;
        for(int j = 1; j <= m; ++j){
            int x; cin >> x;
            adj[i].pb(x + 1);
            edge[i].insert(x + 1);
        }
        if(m < k) q.push(i);
        sz[i] = m;
    }
    while(!q.empty()){
        int node = q.front();
        q.pop();
        vector <int> v;
        for(auto j : adj[node]) if(!vist[j]) v.pb(j);
        for(int mask = 0; mask < (1 << v.size()); ++mask){
            vector <int> clique; clique.pb(node);
            for(int i = 0; i < v.size(); ++i) if((mask >> i) & 1) clique.pb(v[i]);
            if(clique.size() <= ans) continue;
            bool ok = 1;
            for(int i = 0; i < clique.size(); ++i)
                for(int j = i + 1; j < clique.size(); ++j)
                    ok &= edge[clique[i]].count(clique[j]);
            if(ok) ans = clique.size();
        }
        for(auto i : adj[node]){
            --sz[i];
            if(sz[i] == k - 1) q.push(i);
        }
        vist[node] = 1;
    }
    cout << ans << endl;
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:57:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             for(int i = 0; i < v.size(); ++i) if((mask >> i) & 1) clique.pb(v[i]);
      |                            ~~^~~~~~~~~~
politicaldevelopment.cpp:58:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |             if(clique.size() <= ans) continue;
      |                ~~~~~~~~~~~~~~^~~~~~
politicaldevelopment.cpp:60:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |             for(int i = 0; i < clique.size(); ++i)
      |                            ~~^~~~~~~~~~~~~~~
politicaldevelopment.cpp:61:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |                 for(int j = i + 1; j < clique.size(); ++j)
      |                                    ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14416 KB Output is correct
2 Correct 7 ms 14416 KB Output is correct
3 Correct 11 ms 15080 KB Output is correct
4 Correct 10 ms 15056 KB Output is correct
5 Correct 10 ms 15068 KB Output is correct
6 Correct 10 ms 15056 KB Output is correct
7 Correct 10 ms 15184 KB Output is correct
8 Correct 8 ms 14424 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14416 KB Output is correct
2 Correct 7 ms 14416 KB Output is correct
3 Correct 11 ms 15080 KB Output is correct
4 Correct 10 ms 15056 KB Output is correct
5 Correct 10 ms 15068 KB Output is correct
6 Correct 10 ms 15056 KB Output is correct
7 Correct 10 ms 15184 KB Output is correct
8 Correct 8 ms 14424 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 10 ms 15072 KB Output is correct
12 Correct 10 ms 15056 KB Output is correct
13 Correct 7 ms 14368 KB Output is correct
14 Correct 10 ms 15064 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 10 ms 15172 KB Output is correct
17 Correct 7 ms 14416 KB Output is correct
18 Correct 11 ms 15184 KB Output is correct
19 Correct 8 ms 14508 KB Output is correct
20 Correct 8 ms 14840 KB Output is correct
21 Correct 9 ms 14820 KB Output is correct
22 Correct 8 ms 14432 KB Output is correct
23 Correct 11 ms 15184 KB Output is correct
24 Correct 8 ms 14416 KB Output is correct
25 Correct 11 ms 15184 KB Output is correct
26 Correct 13 ms 15196 KB Output is correct
27 Correct 13 ms 15072 KB Output is correct
28 Correct 13 ms 15172 KB Output is correct
29 Correct 10 ms 15056 KB Output is correct
30 Correct 11 ms 15312 KB Output is correct
31 Correct 11 ms 15192 KB Output is correct
32 Correct 13 ms 15312 KB Output is correct
33 Correct 11 ms 15192 KB Output is correct
34 Correct 11 ms 15300 KB Output is correct
35 Correct 9 ms 14800 KB Output is correct
36 Correct 9 ms 14800 KB Output is correct
37 Correct 9 ms 14800 KB Output is correct
38 Correct 9 ms 14672 KB Output is correct
39 Correct 9 ms 14688 KB Output is correct
40 Correct 13 ms 15588 KB Output is correct
41 Correct 8 ms 14672 KB Output is correct
42 Correct 12 ms 15568 KB Output is correct
43 Correct 14 ms 15576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14420 KB Output is correct
2 Correct 7 ms 14420 KB Output is correct
3 Correct 7 ms 14416 KB Output is correct
4 Correct 7 ms 14416 KB Output is correct
5 Correct 9 ms 14416 KB Output is correct
6 Correct 8 ms 14516 KB Output is correct
7 Correct 7 ms 14348 KB Output is correct
8 Correct 7 ms 14416 KB Output is correct
9 Correct 7 ms 14412 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 1681 ms 42596 KB Output is correct
12 Correct 7 ms 14416 KB Output is correct
13 Correct 889 ms 42560 KB Output is correct
14 Correct 7 ms 14416 KB Output is correct
15 Correct 1674 ms 42592 KB Output is correct
16 Correct 928 ms 42540 KB Output is correct
17 Correct 1308 ms 42640 KB Output is correct
18 Correct 1431 ms 42564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14416 KB Output is correct
2 Correct 7 ms 14416 KB Output is correct
3 Correct 11 ms 15080 KB Output is correct
4 Correct 10 ms 15056 KB Output is correct
5 Correct 10 ms 15068 KB Output is correct
6 Correct 10 ms 15056 KB Output is correct
7 Correct 10 ms 15184 KB Output is correct
8 Correct 8 ms 14424 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 10 ms 15072 KB Output is correct
12 Correct 10 ms 15056 KB Output is correct
13 Correct 7 ms 14368 KB Output is correct
14 Correct 10 ms 15064 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 10 ms 15172 KB Output is correct
17 Correct 7 ms 14416 KB Output is correct
18 Correct 11 ms 15184 KB Output is correct
19 Correct 8 ms 14508 KB Output is correct
20 Correct 8 ms 14840 KB Output is correct
21 Correct 9 ms 14820 KB Output is correct
22 Correct 8 ms 14432 KB Output is correct
23 Correct 11 ms 15184 KB Output is correct
24 Correct 8 ms 14416 KB Output is correct
25 Correct 11 ms 15184 KB Output is correct
26 Correct 13 ms 15196 KB Output is correct
27 Correct 13 ms 15072 KB Output is correct
28 Correct 13 ms 15172 KB Output is correct
29 Correct 10 ms 15056 KB Output is correct
30 Correct 11 ms 15312 KB Output is correct
31 Correct 11 ms 15192 KB Output is correct
32 Correct 13 ms 15312 KB Output is correct
33 Correct 11 ms 15192 KB Output is correct
34 Correct 11 ms 15300 KB Output is correct
35 Correct 9 ms 14800 KB Output is correct
36 Correct 9 ms 14800 KB Output is correct
37 Correct 9 ms 14800 KB Output is correct
38 Correct 9 ms 14672 KB Output is correct
39 Correct 9 ms 14688 KB Output is correct
40 Correct 13 ms 15588 KB Output is correct
41 Correct 8 ms 14672 KB Output is correct
42 Correct 12 ms 15568 KB Output is correct
43 Correct 14 ms 15576 KB Output is correct
44 Correct 54 ms 16840 KB Output is correct
45 Correct 9 ms 14416 KB Output is correct
46 Correct 13 ms 15580 KB Output is correct
47 Correct 32 ms 16728 KB Output is correct
48 Correct 15 ms 15580 KB Output is correct
49 Correct 33 ms 16692 KB Output is correct
50 Correct 49 ms 16660 KB Output is correct
51 Correct 457 ms 19092 KB Output is correct
52 Correct 10 ms 15056 KB Output is correct
53 Correct 1066 ms 19688 KB Output is correct
54 Correct 968 ms 19660 KB Output is correct
55 Correct 10 ms 15044 KB Output is correct
56 Correct 10 ms 15064 KB Output is correct
57 Correct 8 ms 14544 KB Output is correct
58 Correct 1070 ms 19696 KB Output is correct
59 Correct 14 ms 15576 KB Output is correct
60 Correct 10 ms 15184 KB Output is correct
61 Correct 14 ms 15580 KB Output is correct
62 Correct 14 ms 15568 KB Output is correct
63 Correct 50 ms 16668 KB Output is correct
64 Correct 34 ms 16504 KB Output is correct
65 Correct 13 ms 15440 KB Output is correct
66 Correct 14 ms 15628 KB Output is correct
67 Correct 75 ms 17264 KB Output is correct
68 Correct 33 ms 16584 KB Output is correct
69 Correct 12 ms 15440 KB Output is correct
70 Correct 29 ms 16472 KB Output is correct
71 Correct 68 ms 17144 KB Output is correct
72 Correct 72 ms 17116 KB Output is correct
73 Correct 11 ms 15064 KB Output is correct
74 Correct 30 ms 16592 KB Output is correct
75 Correct 63 ms 17160 KB Output is correct
76 Correct 23 ms 15952 KB Output is correct
77 Correct 284 ms 17764 KB Output is correct
78 Correct 10 ms 15056 KB Output is correct
79 Correct 144 ms 16092 KB Output is correct
80 Correct 25 ms 15952 KB Output is correct
81 Correct 291 ms 17756 KB Output is correct
82 Correct 9 ms 14688 KB Output is correct
83 Correct 156 ms 16140 KB Output is correct
84 Correct 156 ms 17104 KB Output is correct
85 Correct 11 ms 14672 KB Output is correct
86 Correct 98 ms 17160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14416 KB Output is correct
2 Correct 7 ms 14416 KB Output is correct
3 Correct 11 ms 15080 KB Output is correct
4 Correct 10 ms 15056 KB Output is correct
5 Correct 10 ms 15068 KB Output is correct
6 Correct 10 ms 15056 KB Output is correct
7 Correct 10 ms 15184 KB Output is correct
8 Correct 8 ms 14424 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 8 ms 14416 KB Output is correct
11 Correct 10 ms 15072 KB Output is correct
12 Correct 10 ms 15056 KB Output is correct
13 Correct 7 ms 14368 KB Output is correct
14 Correct 10 ms 15064 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 10 ms 15172 KB Output is correct
17 Correct 7 ms 14416 KB Output is correct
18 Correct 11 ms 15184 KB Output is correct
19 Correct 8 ms 14508 KB Output is correct
20 Correct 8 ms 14840 KB Output is correct
21 Correct 9 ms 14820 KB Output is correct
22 Correct 8 ms 14432 KB Output is correct
23 Correct 11 ms 15184 KB Output is correct
24 Correct 8 ms 14416 KB Output is correct
25 Correct 11 ms 15184 KB Output is correct
26 Correct 13 ms 15196 KB Output is correct
27 Correct 13 ms 15072 KB Output is correct
28 Correct 13 ms 15172 KB Output is correct
29 Correct 10 ms 15056 KB Output is correct
30 Correct 11 ms 15312 KB Output is correct
31 Correct 11 ms 15192 KB Output is correct
32 Correct 13 ms 15312 KB Output is correct
33 Correct 11 ms 15192 KB Output is correct
34 Correct 11 ms 15300 KB Output is correct
35 Correct 9 ms 14800 KB Output is correct
36 Correct 9 ms 14800 KB Output is correct
37 Correct 9 ms 14800 KB Output is correct
38 Correct 9 ms 14672 KB Output is correct
39 Correct 9 ms 14688 KB Output is correct
40 Correct 13 ms 15588 KB Output is correct
41 Correct 8 ms 14672 KB Output is correct
42 Correct 12 ms 15568 KB Output is correct
43 Correct 14 ms 15576 KB Output is correct
44 Correct 7 ms 14416 KB Output is correct
45 Correct 139 ms 32936 KB Output is correct
46 Correct 78 ms 24384 KB Output is correct
47 Correct 157 ms 33008 KB Output is correct
48 Correct 137 ms 32908 KB Output is correct
49 Correct 40 ms 21956 KB Output is correct
50 Correct 233 ms 38284 KB Output is correct
51 Correct 158 ms 32960 KB Output is correct
52 Correct 36 ms 21960 KB Output is correct
53 Correct 41 ms 21920 KB Output is correct
54 Correct 11 ms 14940 KB Output is correct
55 Correct 219 ms 38340 KB Output is correct
56 Correct 28 ms 19084 KB Output is correct
57 Correct 35 ms 21876 KB Output is correct
58 Correct 54 ms 24392 KB Output is correct
59 Correct 24 ms 19052 KB Output is correct
60 Correct 27 ms 19156 KB Output is correct
61 Correct 55 ms 24392 KB Output is correct
62 Correct 36 ms 21688 KB Output is correct
63 Correct 86 ms 25824 KB Output is correct
64 Correct 23 ms 19152 KB Output is correct
65 Correct 93 ms 28608 KB Output is correct
66 Correct 36 ms 21704 KB Output is correct
67 Correct 71 ms 25808 KB Output is correct
68 Correct 119 ms 27840 KB Output is correct
69 Correct 102 ms 28592 KB Output is correct
70 Correct 38 ms 21700 KB Output is correct
71 Correct 96 ms 27908 KB Output is correct
72 Correct 67 ms 25416 KB Output is correct
73 Correct 139 ms 30324 KB Output is correct
74 Correct 39 ms 21780 KB Output is correct
75 Correct 43 ms 20600 KB Output is correct
76 Correct 69 ms 25360 KB Output is correct
77 Correct 161 ms 30380 KB Output is correct
78 Correct 71 ms 22352 KB Output is correct
79 Correct 43 ms 20584 KB Output is correct
80 Correct 22 ms 17492 KB Output is correct
81 Correct 71 ms 22332 KB Output is correct
82 Correct 97 ms 26992 KB Output is correct
83 Correct 29 ms 17476 KB Output is correct
84 Correct 89 ms 26988 KB Output is correct