답안 #197173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197173 2020-01-19T13:21:02 Z arnold518 Political Development (BOI17_politicaldevelopment) C++14
54 / 100
3000 ms 27720 KB
#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];
vector<int> adj2[MAXN+10];
bool vis[MAXN+10];

int main()
{
	int i, j, k, p;
	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(auto it : chd) for(auto jt : chd) if(adj[it].find(jt)!=adj[it].end()) adj2[it].push_back(jt);

		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(!binary_search(adj2[V[j]].begin(), adj2[V[j]].end(), V[k])) flag=false;
			if(flag) ans=max(ans, (int)V.size()+1); 
		}
		vis[now]=true;
		for(auto it : chd) adj2[it].clear();
		for(auto it : chd) adj[it].erase(now);
		adj[now].clear();
	}
	printf("%d", ans);
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:41: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:43: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(!binary_search(adj2[V[j]].begin(), adj2[V[j]].end(), V[k])) flag=false;
             ~^~~~~~~~~
politicaldevelopment.cpp:43: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(!binary_search(adj2[V[j]].begin(), adj2[V[j]].end(), V[k])) flag=false;
                                         ~^~~~~~~~~
politicaldevelopment.cpp:17:15: warning: unused variable 'p' [-Wunused-variable]
  int i, j, k, p;
               ^
politicaldevelopment.cpp:18: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:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &s);
   ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:23: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 6 ms 3832 KB Output is correct
2 Correct 5 ms 3832 KB Output is correct
3 Correct 128 ms 4344 KB Output is correct
4 Correct 51 ms 4472 KB Output is correct
5 Correct 51 ms 4344 KB Output is correct
6 Correct 61 ms 4344 KB Output is correct
7 Correct 60 ms 4472 KB Output is correct
8 Correct 46 ms 3832 KB Output is correct
9 Correct 5 ms 3832 KB Output is correct
10 Correct 46 ms 3920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3832 KB Output is correct
2 Correct 5 ms 3832 KB Output is correct
3 Correct 128 ms 4344 KB Output is correct
4 Correct 51 ms 4472 KB Output is correct
5 Correct 51 ms 4344 KB Output is correct
6 Correct 61 ms 4344 KB Output is correct
7 Correct 60 ms 4472 KB Output is correct
8 Correct 46 ms 3832 KB Output is correct
9 Correct 5 ms 3832 KB Output is correct
10 Correct 46 ms 3920 KB Output is correct
11 Correct 51 ms 4344 KB Output is correct
12 Correct 52 ms 4472 KB Output is correct
13 Correct 5 ms 3832 KB Output is correct
14 Correct 52 ms 4344 KB Output is correct
15 Correct 5 ms 3832 KB Output is correct
16 Correct 61 ms 4344 KB Output is correct
17 Correct 5 ms 3832 KB Output is correct
18 Correct 60 ms 4344 KB Output is correct
19 Correct 43 ms 3832 KB Output is correct
20 Correct 75 ms 4216 KB Output is correct
21 Correct 74 ms 4088 KB Output is correct
22 Correct 47 ms 3960 KB Output is correct
23 Correct 137 ms 4540 KB Output is correct
24 Correct 47 ms 3832 KB Output is correct
25 Correct 137 ms 4600 KB Output is correct
26 Correct 135 ms 4472 KB Output is correct
27 Correct 107 ms 4472 KB Output is correct
28 Correct 138 ms 4600 KB Output is correct
29 Correct 108 ms 4344 KB Output is correct
30 Correct 125 ms 4628 KB Output is correct
31 Correct 131 ms 4472 KB Output is correct
32 Correct 122 ms 4584 KB Output is correct
33 Correct 126 ms 4472 KB Output is correct
34 Correct 126 ms 4600 KB Output is correct
35 Correct 32 ms 4216 KB Output is correct
36 Correct 32 ms 4216 KB Output is correct
37 Correct 32 ms 4216 KB Output is correct
38 Correct 12 ms 4124 KB Output is correct
39 Correct 12 ms 4088 KB Output is correct
40 Correct 151 ms 5052 KB Output is correct
41 Correct 12 ms 4220 KB Output is correct
42 Correct 149 ms 4984 KB Output is correct
43 Correct 148 ms 4856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 3832 KB Output is correct
2 Correct 5 ms 3960 KB Output is correct
3 Correct 5 ms 3832 KB Output is correct
4 Correct 5 ms 3832 KB Output is correct
5 Correct 5 ms 3832 KB Output is correct
6 Correct 5 ms 3832 KB Output is correct
7 Correct 6 ms 3832 KB Output is correct
8 Correct 5 ms 3832 KB Output is correct
9 Correct 5 ms 3832 KB Output is correct
10 Correct 6 ms 3832 KB Output is correct
11 Execution timed out 3041 ms 27720 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3832 KB Output is correct
2 Correct 5 ms 3832 KB Output is correct
3 Correct 128 ms 4344 KB Output is correct
4 Correct 51 ms 4472 KB Output is correct
5 Correct 51 ms 4344 KB Output is correct
6 Correct 61 ms 4344 KB Output is correct
7 Correct 60 ms 4472 KB Output is correct
8 Correct 46 ms 3832 KB Output is correct
9 Correct 5 ms 3832 KB Output is correct
10 Correct 46 ms 3920 KB Output is correct
11 Correct 51 ms 4344 KB Output is correct
12 Correct 52 ms 4472 KB Output is correct
13 Correct 5 ms 3832 KB Output is correct
14 Correct 52 ms 4344 KB Output is correct
15 Correct 5 ms 3832 KB Output is correct
16 Correct 61 ms 4344 KB Output is correct
17 Correct 5 ms 3832 KB Output is correct
18 Correct 60 ms 4344 KB Output is correct
19 Correct 43 ms 3832 KB Output is correct
20 Correct 75 ms 4216 KB Output is correct
21 Correct 74 ms 4088 KB Output is correct
22 Correct 47 ms 3960 KB Output is correct
23 Correct 137 ms 4540 KB Output is correct
24 Correct 47 ms 3832 KB Output is correct
25 Correct 137 ms 4600 KB Output is correct
26 Correct 135 ms 4472 KB Output is correct
27 Correct 107 ms 4472 KB Output is correct
28 Correct 138 ms 4600 KB Output is correct
29 Correct 108 ms 4344 KB Output is correct
30 Correct 125 ms 4628 KB Output is correct
31 Correct 131 ms 4472 KB Output is correct
32 Correct 122 ms 4584 KB Output is correct
33 Correct 126 ms 4472 KB Output is correct
34 Correct 126 ms 4600 KB Output is correct
35 Correct 32 ms 4216 KB Output is correct
36 Correct 32 ms 4216 KB Output is correct
37 Correct 32 ms 4216 KB Output is correct
38 Correct 12 ms 4124 KB Output is correct
39 Correct 12 ms 4088 KB Output is correct
40 Correct 151 ms 5052 KB Output is correct
41 Correct 12 ms 4220 KB Output is correct
42 Correct 149 ms 4984 KB Output is correct
43 Correct 148 ms 4856 KB Output is correct
44 Correct 199 ms 5968 KB Output is correct
45 Correct 5 ms 3832 KB Output is correct
46 Correct 143 ms 4856 KB Output is correct
47 Correct 157 ms 6008 KB Output is correct
48 Correct 145 ms 4924 KB Output is correct
49 Correct 157 ms 6008 KB Output is correct
50 Correct 155 ms 6056 KB Output is correct
51 Correct 500 ms 8152 KB Output is correct
52 Correct 51 ms 4348 KB Output is correct
53 Correct 757 ms 8564 KB Output is correct
54 Correct 871 ms 8824 KB Output is correct
55 Correct 60 ms 4344 KB Output is correct
56 Correct 51 ms 4344 KB Output is correct
57 Correct 46 ms 3960 KB Output is correct
58 Correct 759 ms 8572 KB Output is correct
59 Correct 106 ms 4988 KB Output is correct
60 Correct 60 ms 4472 KB Output is correct
61 Correct 107 ms 4984 KB Output is correct
62 Correct 111 ms 4984 KB Output is correct
63 Correct 221 ms 5880 KB Output is correct
64 Correct 163 ms 5624 KB Output is correct
65 Correct 162 ms 5064 KB Output is correct
66 Correct 106 ms 4856 KB Output is correct
67 Correct 198 ms 6392 KB Output is correct
68 Correct 155 ms 5624 KB Output is correct
69 Correct 141 ms 4728 KB Output is correct
70 Correct 148 ms 5756 KB Output is correct
71 Correct 186 ms 6264 KB Output is correct
72 Correct 180 ms 6264 KB Output is correct
73 Correct 108 ms 4560 KB Output is correct
74 Correct 150 ms 5752 KB Output is correct
75 Correct 179 ms 6312 KB Output is correct
76 Correct 133 ms 5368 KB Output is correct
77 Correct 259 ms 6852 KB Output is correct
78 Correct 108 ms 4472 KB Output is correct
79 Correct 97 ms 5368 KB Output is correct
80 Correct 145 ms 5368 KB Output is correct
81 Correct 258 ms 6904 KB Output is correct
82 Correct 12 ms 4088 KB Output is correct
83 Correct 99 ms 5368 KB Output is correct
84 Correct 181 ms 6136 KB Output is correct
85 Correct 11 ms 4216 KB Output is correct
86 Correct 179 ms 6264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3832 KB Output is correct
2 Correct 5 ms 3832 KB Output is correct
3 Correct 128 ms 4344 KB Output is correct
4 Correct 51 ms 4472 KB Output is correct
5 Correct 51 ms 4344 KB Output is correct
6 Correct 61 ms 4344 KB Output is correct
7 Correct 60 ms 4472 KB Output is correct
8 Correct 46 ms 3832 KB Output is correct
9 Correct 5 ms 3832 KB Output is correct
10 Correct 46 ms 3920 KB Output is correct
11 Correct 51 ms 4344 KB Output is correct
12 Correct 52 ms 4472 KB Output is correct
13 Correct 5 ms 3832 KB Output is correct
14 Correct 52 ms 4344 KB Output is correct
15 Correct 5 ms 3832 KB Output is correct
16 Correct 61 ms 4344 KB Output is correct
17 Correct 5 ms 3832 KB Output is correct
18 Correct 60 ms 4344 KB Output is correct
19 Correct 43 ms 3832 KB Output is correct
20 Correct 75 ms 4216 KB Output is correct
21 Correct 74 ms 4088 KB Output is correct
22 Correct 47 ms 3960 KB Output is correct
23 Correct 137 ms 4540 KB Output is correct
24 Correct 47 ms 3832 KB Output is correct
25 Correct 137 ms 4600 KB Output is correct
26 Correct 135 ms 4472 KB Output is correct
27 Correct 107 ms 4472 KB Output is correct
28 Correct 138 ms 4600 KB Output is correct
29 Correct 108 ms 4344 KB Output is correct
30 Correct 125 ms 4628 KB Output is correct
31 Correct 131 ms 4472 KB Output is correct
32 Correct 122 ms 4584 KB Output is correct
33 Correct 126 ms 4472 KB Output is correct
34 Correct 126 ms 4600 KB Output is correct
35 Correct 32 ms 4216 KB Output is correct
36 Correct 32 ms 4216 KB Output is correct
37 Correct 32 ms 4216 KB Output is correct
38 Correct 12 ms 4124 KB Output is correct
39 Correct 12 ms 4088 KB Output is correct
40 Correct 151 ms 5052 KB Output is correct
41 Correct 12 ms 4220 KB Output is correct
42 Correct 149 ms 4984 KB Output is correct
43 Correct 148 ms 4856 KB Output is correct
44 Correct 5 ms 3832 KB Output is correct
45 Execution timed out 3069 ms 20032 KB Time limit exceeded
46 Halted 0 ms 0 KB -