답안 #197172

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197172 2020-01-19T13:20:01 Z arnold518 Political Development (BOI17_politicaldevelopment) C++14
4 / 100
134 ms 4472 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(it)!=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 6 ms 3832 KB Output is correct
3 Correct 134 ms 4344 KB Output is correct
4 Correct 52 ms 4472 KB Output is correct
5 Correct 52 ms 4344 KB Output is correct
6 Correct 65 ms 4472 KB Output is correct
7 Correct 63 ms 4472 KB Output is correct
8 Correct 49 ms 3832 KB Output is correct
9 Correct 5 ms 3832 KB Output is correct
10 Correct 47 ms 3832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3832 KB Output is correct
2 Correct 6 ms 3832 KB Output is correct
3 Correct 134 ms 4344 KB Output is correct
4 Correct 52 ms 4472 KB Output is correct
5 Correct 52 ms 4344 KB Output is correct
6 Correct 65 ms 4472 KB Output is correct
7 Correct 63 ms 4472 KB Output is correct
8 Correct 49 ms 3832 KB Output is correct
9 Correct 5 ms 3832 KB Output is correct
10 Correct 47 ms 3832 KB Output is correct
11 Correct 51 ms 4356 KB Output is correct
12 Correct 51 ms 4344 KB Output is correct
13 Correct 5 ms 3832 KB Output is correct
14 Correct 51 ms 4472 KB Output is correct
15 Incorrect 5 ms 3832 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 3704 KB Output is correct
2 Incorrect 9 ms 3832 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3832 KB Output is correct
2 Correct 6 ms 3832 KB Output is correct
3 Correct 134 ms 4344 KB Output is correct
4 Correct 52 ms 4472 KB Output is correct
5 Correct 52 ms 4344 KB Output is correct
6 Correct 65 ms 4472 KB Output is correct
7 Correct 63 ms 4472 KB Output is correct
8 Correct 49 ms 3832 KB Output is correct
9 Correct 5 ms 3832 KB Output is correct
10 Correct 47 ms 3832 KB Output is correct
11 Correct 51 ms 4356 KB Output is correct
12 Correct 51 ms 4344 KB Output is correct
13 Correct 5 ms 3832 KB Output is correct
14 Correct 51 ms 4472 KB Output is correct
15 Incorrect 5 ms 3832 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3832 KB Output is correct
2 Correct 6 ms 3832 KB Output is correct
3 Correct 134 ms 4344 KB Output is correct
4 Correct 52 ms 4472 KB Output is correct
5 Correct 52 ms 4344 KB Output is correct
6 Correct 65 ms 4472 KB Output is correct
7 Correct 63 ms 4472 KB Output is correct
8 Correct 49 ms 3832 KB Output is correct
9 Correct 5 ms 3832 KB Output is correct
10 Correct 47 ms 3832 KB Output is correct
11 Correct 51 ms 4356 KB Output is correct
12 Correct 51 ms 4344 KB Output is correct
13 Correct 5 ms 3832 KB Output is correct
14 Correct 51 ms 4472 KB Output is correct
15 Incorrect 5 ms 3832 KB Output isn't correct
16 Halted 0 ms 0 KB -