Submission #197159

# Submission time Handle Problem Language Result Execution time Memory
197159 2020-01-19T11:25:06 Z dndhk Political Development (BOI17_politicaldevelopment) C++14
100 / 100
972 ms 31652 KB
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1000000000;
const int MAX_N = 50000;
const int MAX_K = 10;

int N, K;
vector<int> gp[MAX_N+1];
bool chk[MAX_N+1];
int deg[MAX_N+1];

priority_queue<pii, vector<pii>, greater<pii> > pq;
vector<int> vt;
int ans, idx;
vector<int> v;
set<pii> st;

void calc(int x){
	if(x==vt.size()){
		for(int i=0; i<v.size(); i++){
			for(int j=i+1; j<v.size(); j++){
				if(st.find({v[i], v[j]})==st.end())	return;
			}
		}
		ans = max(ans, (int)v.size());
		return;
	}else{
		calc(x+1);
		v.pb(vt[x]);
		calc(x+1);
		v.pop_back();
	}
}

int main(){
	scanf("%d%d", &N, &K);
	for(int i=0; i<N; i++){
		int x, y; scanf("%d", &x);
		deg[i] = x;
		while(x--){
			scanf("%d", &y);
			st.insert({i, y});
			gp[i].pb(y);
		}
		pq.push({deg[i], i});
	}
	while(!pq.empty()){
		pii now = pq.top(); pq.pop();
		if(chk[now.second])	continue;
		idx = now.second;
		chk[idx] = true;
		while(!vt.empty())	vt.pop_back();
		for(int i : gp[idx]){
			if(!chk[i]){
				vt.pb(i);
			}
		}
		while(!v.empty())	v.pop_back();
		v.pb(idx);
		calc(0);
		for(int i : gp[idx]){
			if(!chk[i]){
				deg[i]--;
				pq.push({deg[i], i});
			}
		}
	}
	cout<<ans;
}

Compilation message

politicaldevelopment.cpp: In function 'void calc(int)':
politicaldevelopment.cpp:27:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(x==vt.size()){
     ~^~~~~~~~~~~
politicaldevelopment.cpp:28:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<v.size(); i++){
                ~^~~~~~~~~
politicaldevelopment.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=i+1; j<v.size(); j++){
                   ~^~~~~~~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &K);
  ~~~~~^~~~~~~~~~~~~~~~
politicaldevelopment.cpp:46:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x, y; scanf("%d", &x);
             ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:49:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &y);
    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1528 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 10 ms 2296 KB Output is correct
4 Correct 9 ms 2296 KB Output is correct
5 Correct 9 ms 2296 KB Output is correct
6 Correct 9 ms 2324 KB Output is correct
7 Correct 9 ms 2296 KB Output is correct
8 Correct 4 ms 1656 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 4 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1528 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 10 ms 2296 KB Output is correct
4 Correct 9 ms 2296 KB Output is correct
5 Correct 9 ms 2296 KB Output is correct
6 Correct 9 ms 2324 KB Output is correct
7 Correct 9 ms 2296 KB Output is correct
8 Correct 4 ms 1656 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 4 ms 1656 KB Output is correct
11 Correct 8 ms 2296 KB Output is correct
12 Correct 11 ms 2360 KB Output is correct
13 Correct 4 ms 1528 KB Output is correct
14 Correct 10 ms 2296 KB Output is correct
15 Correct 4 ms 1528 KB Output is correct
16 Correct 10 ms 2296 KB Output is correct
17 Correct 3 ms 1528 KB Output is correct
18 Correct 31 ms 2296 KB Output is correct
19 Correct 5 ms 1656 KB Output is correct
20 Correct 7 ms 2040 KB Output is correct
21 Correct 8 ms 2040 KB Output is correct
22 Correct 4 ms 1660 KB Output is correct
23 Correct 13 ms 2424 KB Output is correct
24 Correct 4 ms 1656 KB Output is correct
25 Correct 13 ms 2424 KB Output is correct
26 Correct 12 ms 2268 KB Output is correct
27 Correct 11 ms 2296 KB Output is correct
28 Correct 12 ms 2296 KB Output is correct
29 Correct 10 ms 2296 KB Output is correct
30 Correct 13 ms 2552 KB Output is correct
31 Correct 13 ms 2424 KB Output is correct
32 Correct 13 ms 2492 KB Output is correct
33 Correct 13 ms 2424 KB Output is correct
34 Correct 13 ms 2424 KB Output is correct
35 Correct 8 ms 1912 KB Output is correct
36 Correct 12 ms 2040 KB Output is correct
37 Correct 10 ms 2040 KB Output is correct
38 Correct 6 ms 1912 KB Output is correct
39 Correct 7 ms 1912 KB Output is correct
40 Correct 19 ms 2936 KB Output is correct
41 Correct 7 ms 1912 KB Output is correct
42 Correct 19 ms 2936 KB Output is correct
43 Correct 17 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1660 KB Output is correct
2 Correct 3 ms 1528 KB Output is correct
3 Correct 3 ms 1528 KB Output is correct
4 Correct 4 ms 1528 KB Output is correct
5 Correct 3 ms 1528 KB Output is correct
6 Correct 4 ms 1528 KB Output is correct
7 Correct 3 ms 1528 KB Output is correct
8 Correct 3 ms 1528 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 4 ms 1548 KB Output is correct
11 Correct 948 ms 31612 KB Output is correct
12 Correct 3 ms 1528 KB Output is correct
13 Correct 959 ms 31572 KB Output is correct
14 Correct 3 ms 1528 KB Output is correct
15 Correct 946 ms 31652 KB Output is correct
16 Correct 972 ms 31476 KB Output is correct
17 Correct 944 ms 31492 KB Output is correct
18 Correct 956 ms 31540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1528 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 10 ms 2296 KB Output is correct
4 Correct 9 ms 2296 KB Output is correct
5 Correct 9 ms 2296 KB Output is correct
6 Correct 9 ms 2324 KB Output is correct
7 Correct 9 ms 2296 KB Output is correct
8 Correct 4 ms 1656 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 4 ms 1656 KB Output is correct
11 Correct 8 ms 2296 KB Output is correct
12 Correct 11 ms 2360 KB Output is correct
13 Correct 4 ms 1528 KB Output is correct
14 Correct 10 ms 2296 KB Output is correct
15 Correct 4 ms 1528 KB Output is correct
16 Correct 10 ms 2296 KB Output is correct
17 Correct 3 ms 1528 KB Output is correct
18 Correct 31 ms 2296 KB Output is correct
19 Correct 5 ms 1656 KB Output is correct
20 Correct 7 ms 2040 KB Output is correct
21 Correct 8 ms 2040 KB Output is correct
22 Correct 4 ms 1660 KB Output is correct
23 Correct 13 ms 2424 KB Output is correct
24 Correct 4 ms 1656 KB Output is correct
25 Correct 13 ms 2424 KB Output is correct
26 Correct 12 ms 2268 KB Output is correct
27 Correct 11 ms 2296 KB Output is correct
28 Correct 12 ms 2296 KB Output is correct
29 Correct 10 ms 2296 KB Output is correct
30 Correct 13 ms 2552 KB Output is correct
31 Correct 13 ms 2424 KB Output is correct
32 Correct 13 ms 2492 KB Output is correct
33 Correct 13 ms 2424 KB Output is correct
34 Correct 13 ms 2424 KB Output is correct
35 Correct 8 ms 1912 KB Output is correct
36 Correct 12 ms 2040 KB Output is correct
37 Correct 10 ms 2040 KB Output is correct
38 Correct 6 ms 1912 KB Output is correct
39 Correct 7 ms 1912 KB Output is correct
40 Correct 19 ms 2936 KB Output is correct
41 Correct 7 ms 1912 KB Output is correct
42 Correct 19 ms 2936 KB Output is correct
43 Correct 17 ms 2936 KB Output is correct
44 Correct 143 ms 3920 KB Output is correct
45 Correct 4 ms 1528 KB Output is correct
46 Correct 20 ms 2936 KB Output is correct
47 Correct 48 ms 4216 KB Output is correct
48 Correct 19 ms 2936 KB Output is correct
49 Correct 49 ms 4188 KB Output is correct
50 Correct 50 ms 4216 KB Output is correct
51 Correct 342 ms 6900 KB Output is correct
52 Correct 9 ms 2296 KB Output is correct
53 Correct 605 ms 7408 KB Output is correct
54 Correct 648 ms 7576 KB Output is correct
55 Correct 10 ms 2296 KB Output is correct
56 Correct 9 ms 2296 KB Output is correct
57 Correct 4 ms 1656 KB Output is correct
58 Correct 697 ms 7524 KB Output is correct
59 Correct 21 ms 2808 KB Output is correct
60 Correct 10 ms 2296 KB Output is correct
61 Correct 19 ms 2808 KB Output is correct
62 Correct 21 ms 2936 KB Output is correct
63 Correct 145 ms 3932 KB Output is correct
64 Correct 81 ms 3704 KB Output is correct
65 Correct 17 ms 2680 KB Output is correct
66 Correct 21 ms 2808 KB Output is correct
67 Correct 106 ms 4728 KB Output is correct
68 Correct 80 ms 3704 KB Output is correct
69 Correct 16 ms 2808 KB Output is correct
70 Correct 44 ms 3832 KB Output is correct
71 Correct 103 ms 4728 KB Output is correct
72 Correct 84 ms 4544 KB Output is correct
73 Correct 10 ms 2296 KB Output is correct
74 Correct 44 ms 3832 KB Output is correct
75 Correct 86 ms 4600 KB Output is correct
76 Correct 27 ms 3324 KB Output is correct
77 Correct 146 ms 5192 KB Output is correct
78 Correct 10 ms 2296 KB Output is correct
79 Correct 70 ms 3464 KB Output is correct
80 Correct 27 ms 3448 KB Output is correct
81 Correct 148 ms 5376 KB Output is correct
82 Correct 6 ms 1784 KB Output is correct
83 Correct 71 ms 3448 KB Output is correct
84 Correct 77 ms 4700 KB Output is correct
85 Correct 6 ms 1784 KB Output is correct
86 Correct 76 ms 4600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1528 KB Output is correct
2 Correct 3 ms 1532 KB Output is correct
3 Correct 10 ms 2296 KB Output is correct
4 Correct 9 ms 2296 KB Output is correct
5 Correct 9 ms 2296 KB Output is correct
6 Correct 9 ms 2324 KB Output is correct
7 Correct 9 ms 2296 KB Output is correct
8 Correct 4 ms 1656 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 4 ms 1656 KB Output is correct
11 Correct 8 ms 2296 KB Output is correct
12 Correct 11 ms 2360 KB Output is correct
13 Correct 4 ms 1528 KB Output is correct
14 Correct 10 ms 2296 KB Output is correct
15 Correct 4 ms 1528 KB Output is correct
16 Correct 10 ms 2296 KB Output is correct
17 Correct 3 ms 1528 KB Output is correct
18 Correct 31 ms 2296 KB Output is correct
19 Correct 5 ms 1656 KB Output is correct
20 Correct 7 ms 2040 KB Output is correct
21 Correct 8 ms 2040 KB Output is correct
22 Correct 4 ms 1660 KB Output is correct
23 Correct 13 ms 2424 KB Output is correct
24 Correct 4 ms 1656 KB Output is correct
25 Correct 13 ms 2424 KB Output is correct
26 Correct 12 ms 2268 KB Output is correct
27 Correct 11 ms 2296 KB Output is correct
28 Correct 12 ms 2296 KB Output is correct
29 Correct 10 ms 2296 KB Output is correct
30 Correct 13 ms 2552 KB Output is correct
31 Correct 13 ms 2424 KB Output is correct
32 Correct 13 ms 2492 KB Output is correct
33 Correct 13 ms 2424 KB Output is correct
34 Correct 13 ms 2424 KB Output is correct
35 Correct 8 ms 1912 KB Output is correct
36 Correct 12 ms 2040 KB Output is correct
37 Correct 10 ms 2040 KB Output is correct
38 Correct 6 ms 1912 KB Output is correct
39 Correct 7 ms 1912 KB Output is correct
40 Correct 19 ms 2936 KB Output is correct
41 Correct 7 ms 1912 KB Output is correct
42 Correct 19 ms 2936 KB Output is correct
43 Correct 17 ms 2936 KB Output is correct
44 Correct 3 ms 1528 KB Output is correct
45 Correct 377 ms 22124 KB Output is correct
46 Correct 156 ms 11972 KB Output is correct
47 Correct 396 ms 22184 KB Output is correct
48 Correct 381 ms 22000 KB Output is correct
49 Correct 83 ms 9324 KB Output is correct
50 Correct 507 ms 27324 KB Output is correct
51 Correct 406 ms 22124 KB Output is correct
52 Correct 70 ms 9268 KB Output is correct
53 Correct 87 ms 9328 KB Output is correct
54 Correct 14 ms 2420 KB Output is correct
55 Correct 522 ms 27376 KB Output is correct
56 Correct 49 ms 6508 KB Output is correct
57 Correct 70 ms 9456 KB Output is correct
58 Correct 153 ms 11632 KB Output is correct
59 Correct 51 ms 6404 KB Output is correct
60 Correct 51 ms 6388 KB Output is correct
61 Correct 155 ms 11656 KB Output is correct
62 Correct 112 ms 9120 KB Output is correct
63 Correct 203 ms 13808 KB Output is correct
64 Correct 51 ms 6384 KB Output is correct
65 Correct 267 ms 16752 KB Output is correct
66 Correct 110 ms 9072 KB Output is correct
67 Correct 187 ms 13824 KB Output is correct
68 Correct 247 ms 15956 KB Output is correct
69 Correct 265 ms 16752 KB Output is correct
70 Correct 111 ms 9068 KB Output is correct
71 Correct 250 ms 16112 KB Output is correct
72 Correct 190 ms 13424 KB Output is correct
73 Correct 312 ms 18544 KB Output is correct
74 Correct 117 ms 9072 KB Output is correct
75 Correct 100 ms 8180 KB Output is correct
76 Correct 183 ms 13424 KB Output is correct
77 Correct 306 ms 18584 KB Output is correct
78 Correct 145 ms 10100 KB Output is correct
79 Correct 100 ms 8180 KB Output is correct
80 Correct 40 ms 4856 KB Output is correct
81 Correct 145 ms 9972 KB Output is correct
82 Correct 222 ms 14944 KB Output is correct
83 Correct 41 ms 4856 KB Output is correct
84 Correct 221 ms 15088 KB Output is correct