답안 #197162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197162 2020-01-19T12:05:43 Z arnold518 Political Development (BOI17_politicaldevelopment) C++14
54 / 100
3000 ms 24748 KB
#pragma GCC optimize ("O3")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

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

const int MAXN = 5e4;

int N, K, ans=1;
set<int> adj[MAXN+10];
bool vis[MAXN+10];

int main()
{
	int i, j, k;
	scanf("%d%d", &N, &K);
	for(i=1; i<=N; i++)
	{
		int s;
		scanf("%d", &s);
		while(s--) { int t; scanf("%d", &t); adj[i].insert(t+1); }
	}

	while(1)
	{
		pii t(987654321, 0);
		for(i=1; i<=N; i++) if(!vis[i]) t=min(t, pii(adj[i].size(), i));
		if(t.second==0) break;
		int now=t.second;

		vector<int> chd;
		for(auto it : adj[now]) chd.push_back(it);

		for(i=0; i<(1<<chd.size()); i++)
		{
			vector<int> V;
			for(j=0; j<chd.size(); j++) if(i&(1<<j)) V.push_back(chd[j]);
			bool flag=true;
			for(j=0; j<V.size(); j++) for(k=j+1; k<V.size(); k++) if(adj[V[j]].find(V[k])==adj[V[j]].end()) flag=false;
			if(flag) ans=max(ans, (int)V.size()+1); 
		}
		vis[now]=true;
		for(auto it : chd) adj[it].erase(now);
		adj[now].clear();
	}
	printf("%d", ans);
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:42:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(j=0; j<chd.size(); j++) if(i&(1<<j)) V.push_back(chd[j]);
             ~^~~~~~~~~~~
politicaldevelopment.cpp:44:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(j=0; j<V.size(); j++) for(k=j+1; k<V.size(); k++) if(adj[V[j]].find(V[k])==adj[V[j]].end()) flag=false;
             ~^~~~~~~~~
politicaldevelopment.cpp:44:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(j=0; j<V.size(); j++) for(k=j+1; k<V.size(); k++) if(adj[V[j]].find(V[k])==adj[V[j]].end()) flag=false;
                                         ~^~~~~~~~~
politicaldevelopment.cpp:21: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:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &s);
   ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:26:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   while(s--) { int t; scanf("%d", &t); adj[i].insert(t+1); }
                       ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 61 ms 3272 KB Output is correct
4 Correct 54 ms 3292 KB Output is correct
5 Correct 49 ms 3192 KB Output is correct
6 Correct 51 ms 3192 KB Output is correct
7 Correct 51 ms 3192 KB Output is correct
8 Correct 43 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 45 ms 2684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 61 ms 3272 KB Output is correct
4 Correct 54 ms 3292 KB Output is correct
5 Correct 49 ms 3192 KB Output is correct
6 Correct 51 ms 3192 KB Output is correct
7 Correct 51 ms 3192 KB Output is correct
8 Correct 43 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 45 ms 2684 KB Output is correct
11 Correct 50 ms 3248 KB Output is correct
12 Correct 50 ms 3552 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 49 ms 3192 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 51 ms 3192 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 51 ms 3192 KB Output is correct
19 Correct 45 ms 2680 KB Output is correct
20 Correct 48 ms 3024 KB Output is correct
21 Correct 48 ms 2940 KB Output is correct
22 Correct 45 ms 2680 KB Output is correct
23 Correct 71 ms 3324 KB Output is correct
24 Correct 44 ms 2680 KB Output is correct
25 Correct 71 ms 3320 KB Output is correct
26 Correct 77 ms 3320 KB Output is correct
27 Correct 66 ms 3192 KB Output is correct
28 Correct 72 ms 3324 KB Output is correct
29 Correct 64 ms 3192 KB Output is correct
30 Correct 63 ms 3324 KB Output is correct
31 Correct 65 ms 3320 KB Output is correct
32 Correct 63 ms 3448 KB Output is correct
33 Correct 67 ms 3320 KB Output is correct
34 Correct 65 ms 3404 KB Output is correct
35 Correct 20 ms 2940 KB Output is correct
36 Correct 21 ms 3064 KB Output is correct
37 Correct 22 ms 3064 KB Output is correct
38 Correct 10 ms 2936 KB Output is correct
39 Correct 11 ms 2848 KB Output is correct
40 Correct 84 ms 3832 KB Output is correct
41 Correct 10 ms 2936 KB Output is correct
42 Correct 80 ms 3808 KB Output is correct
43 Correct 86 ms 3704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 2680 KB Output is correct
2 Correct 5 ms 2756 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2728 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 8 ms 2808 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Execution timed out 3026 ms 24748 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 61 ms 3272 KB Output is correct
4 Correct 54 ms 3292 KB Output is correct
5 Correct 49 ms 3192 KB Output is correct
6 Correct 51 ms 3192 KB Output is correct
7 Correct 51 ms 3192 KB Output is correct
8 Correct 43 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 45 ms 2684 KB Output is correct
11 Correct 50 ms 3248 KB Output is correct
12 Correct 50 ms 3552 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 49 ms 3192 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 51 ms 3192 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 51 ms 3192 KB Output is correct
19 Correct 45 ms 2680 KB Output is correct
20 Correct 48 ms 3024 KB Output is correct
21 Correct 48 ms 2940 KB Output is correct
22 Correct 45 ms 2680 KB Output is correct
23 Correct 71 ms 3324 KB Output is correct
24 Correct 44 ms 2680 KB Output is correct
25 Correct 71 ms 3320 KB Output is correct
26 Correct 77 ms 3320 KB Output is correct
27 Correct 66 ms 3192 KB Output is correct
28 Correct 72 ms 3324 KB Output is correct
29 Correct 64 ms 3192 KB Output is correct
30 Correct 63 ms 3324 KB Output is correct
31 Correct 65 ms 3320 KB Output is correct
32 Correct 63 ms 3448 KB Output is correct
33 Correct 67 ms 3320 KB Output is correct
34 Correct 65 ms 3404 KB Output is correct
35 Correct 20 ms 2940 KB Output is correct
36 Correct 21 ms 3064 KB Output is correct
37 Correct 22 ms 3064 KB Output is correct
38 Correct 10 ms 2936 KB Output is correct
39 Correct 11 ms 2848 KB Output is correct
40 Correct 84 ms 3832 KB Output is correct
41 Correct 10 ms 2936 KB Output is correct
42 Correct 80 ms 3808 KB Output is correct
43 Correct 86 ms 3704 KB Output is correct
44 Correct 158 ms 4856 KB Output is correct
45 Correct 4 ms 2680 KB Output is correct
46 Correct 83 ms 3832 KB Output is correct
47 Correct 111 ms 4700 KB Output is correct
48 Correct 81 ms 3704 KB Output is correct
49 Correct 115 ms 4728 KB Output is correct
50 Correct 112 ms 4856 KB Output is correct
51 Correct 623 ms 6884 KB Output is correct
52 Correct 54 ms 3192 KB Output is correct
53 Correct 1225 ms 7400 KB Output is correct
54 Correct 1109 ms 7316 KB Output is correct
55 Correct 51 ms 3192 KB Output is correct
56 Correct 50 ms 3240 KB Output is correct
57 Correct 45 ms 2680 KB Output is correct
58 Correct 1155 ms 7224 KB Output is correct
59 Correct 66 ms 3752 KB Output is correct
60 Correct 50 ms 3192 KB Output is correct
61 Correct 63 ms 3704 KB Output is correct
62 Correct 67 ms 3832 KB Output is correct
63 Correct 157 ms 4856 KB Output is correct
64 Correct 112 ms 4444 KB Output is correct
65 Correct 79 ms 3704 KB Output is correct
66 Correct 66 ms 3704 KB Output is correct
67 Correct 162 ms 5240 KB Output is correct
68 Correct 112 ms 4548 KB Output is correct
69 Correct 78 ms 3576 KB Output is correct
70 Correct 99 ms 4472 KB Output is correct
71 Correct 156 ms 5112 KB Output is correct
72 Correct 141 ms 5212 KB Output is correct
73 Correct 64 ms 3244 KB Output is correct
74 Correct 104 ms 4716 KB Output is correct
75 Correct 142 ms 5112 KB Output is correct
76 Correct 87 ms 4104 KB Output is correct
77 Correct 265 ms 5660 KB Output is correct
78 Correct 64 ms 3192 KB Output is correct
79 Correct 103 ms 3960 KB Output is correct
80 Correct 90 ms 3960 KB Output is correct
81 Correct 258 ms 5404 KB Output is correct
82 Correct 9 ms 2808 KB Output is correct
83 Correct 106 ms 4096 KB Output is correct
84 Correct 144 ms 4828 KB Output is correct
85 Correct 9 ms 2936 KB Output is correct
86 Correct 149 ms 4828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 61 ms 3272 KB Output is correct
4 Correct 54 ms 3292 KB Output is correct
5 Correct 49 ms 3192 KB Output is correct
6 Correct 51 ms 3192 KB Output is correct
7 Correct 51 ms 3192 KB Output is correct
8 Correct 43 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 45 ms 2684 KB Output is correct
11 Correct 50 ms 3248 KB Output is correct
12 Correct 50 ms 3552 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 49 ms 3192 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 51 ms 3192 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 51 ms 3192 KB Output is correct
19 Correct 45 ms 2680 KB Output is correct
20 Correct 48 ms 3024 KB Output is correct
21 Correct 48 ms 2940 KB Output is correct
22 Correct 45 ms 2680 KB Output is correct
23 Correct 71 ms 3324 KB Output is correct
24 Correct 44 ms 2680 KB Output is correct
25 Correct 71 ms 3320 KB Output is correct
26 Correct 77 ms 3320 KB Output is correct
27 Correct 66 ms 3192 KB Output is correct
28 Correct 72 ms 3324 KB Output is correct
29 Correct 64 ms 3192 KB Output is correct
30 Correct 63 ms 3324 KB Output is correct
31 Correct 65 ms 3320 KB Output is correct
32 Correct 63 ms 3448 KB Output is correct
33 Correct 67 ms 3320 KB Output is correct
34 Correct 65 ms 3404 KB Output is correct
35 Correct 20 ms 2940 KB Output is correct
36 Correct 21 ms 3064 KB Output is correct
37 Correct 22 ms 3064 KB Output is correct
38 Correct 10 ms 2936 KB Output is correct
39 Correct 11 ms 2848 KB Output is correct
40 Correct 84 ms 3832 KB Output is correct
41 Correct 10 ms 2936 KB Output is correct
42 Correct 80 ms 3808 KB Output is correct
43 Correct 86 ms 3704 KB Output is correct
44 Correct 4 ms 2680 KB Output is correct
45 Execution timed out 3092 ms 16992 KB Time limit exceeded
46 Halted 0 ms 0 KB -