답안 #486319

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486319 2021-11-11T08:38:42 Z Koosha_mv Political Development (BOI17_politicaldevelopment) C++14
100 / 100
201 ms 34904 KB
#include <bits/stdc++.h>
using namespace std;
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define Add(x,y) x=(x+y)%mod
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=1e6+99,K=15;

int n,k,ans,a[N],mark[N],deg[N],fb[(1<<K)],dp[(1<<K)],adj[K];
vector<int> v,g[N];

void make(){
	f(i,0,n){
		vector<int> v;
		f(j,0,g[i].size()){
			if(mark[i]<mark[g[i][j]]){
				v.pb(g[i][j]);
			}
		}
		g[i]=v;
	}
	f(mask,1,(1<<K)){
		f(i,0,K){
			if(mask&(1<<i)){
				fb[mask]=i;
			}
		}
	}
	fill(mark,mark+N,-1);
}
void max_ind(int n){
	dp[0]=1;
	f(mask,1,(1<<n)){
		int u=fb[mask];
		dp[mask]=(dp[mask^(1<<u)] && (adj[u]&mask)==(mask^(1<<u)));
		if(dp[mask]){
			maxm(ans,nb(mask));
		}
	}
}
void solve(vector<int> v){
	f(i,0,K){
		adj[i]=0;
	}
	f(i,0,v.size()){
		mark[v[i]]=i;
	}
	f(i,0,v.size()){
		int u=v[i];
		f(j,0,g[u].size()){
			if(mark[g[u][j]]!=-1){
				int _u=mark[u],_v=mark[g[u][j]];
				adj[_u]|=(1<<_v);
				adj[_v]|=(1<<_u);
			}
		}
	}
	max_ind(v.size());
	f(i,0,v.size()){
		mark[v[i]]=-1;
	}
}

int main(){
	cin>>n>>k;
	k=10;
	f(i,0,n){
		int x;
		cin>>deg[i];
		f(j,0,deg[i]){
			cin>>x;
			g[i].pb(x);
		}
	}
	f(i,0,n){
		if(deg[i]<k){
			v.pb(i);
		}
	}
	f(i,0,v.size()){
		int u=v[i];
		mark[u]=i;
		f(j,0,g[u].size()){
			if(--deg[g[u][j]]==k-1){
				v.pb(g[u][j]);
			}
		}
	}
	make();
	f(t,0,v.size()){
		int u=v[t];
		solve(g[u]);
	}
	cout<<ans+1;
}

Compilation message

politicaldevelopment.cpp: In function 'void make()':
politicaldevelopment.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   28 |   f(j,0,g[i].size()){
      |     ~~~~~~~~~~~~~~~            
politicaldevelopment.cpp:28:3: note: in expansion of macro 'f'
   28 |   f(j,0,g[i].size()){
      |   ^
politicaldevelopment.cpp: In function 'void solve(std::vector<int>)':
politicaldevelopment.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   58 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:58:2: note: in expansion of macro 'f'
   58 |  f(i,0,v.size()){
      |  ^
politicaldevelopment.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   61 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:61:2: note: in expansion of macro 'f'
   61 |  f(i,0,v.size()){
      |  ^
politicaldevelopment.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   63 |   f(j,0,g[u].size()){
      |     ~~~~~~~~~~~~~~~            
politicaldevelopment.cpp:63:3: note: in expansion of macro 'f'
   63 |   f(j,0,g[u].size()){
      |   ^
politicaldevelopment.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   72 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:72:2: note: in expansion of macro 'f'
   72 |  f(i,0,v.size()){
      |  ^
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   93 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:93:2: note: in expansion of macro 'f'
   93 |  f(i,0,v.size()){
      |  ^
politicaldevelopment.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   96 |   f(j,0,g[u].size()){
      |     ~~~~~~~~~~~~~~~            
politicaldevelopment.cpp:96:3: note: in expansion of macro 'f'
   96 |   f(j,0,g[u].size()){
      |   ^
politicaldevelopment.cpp:7:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define f(i,a,b) for(int i=a;i<b;i++)
......
  103 |  f(t,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:103:2: note: in expansion of macro 'f'
  103 |  f(t,0,v.size()){
      |  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 27724 KB Output is correct
2 Correct 18 ms 27828 KB Output is correct
3 Correct 20 ms 28020 KB Output is correct
4 Correct 21 ms 28092 KB Output is correct
5 Correct 19 ms 27980 KB Output is correct
6 Correct 20 ms 28104 KB Output is correct
7 Correct 19 ms 27980 KB Output is correct
8 Correct 16 ms 27908 KB Output is correct
9 Correct 15 ms 27836 KB Output is correct
10 Correct 16 ms 27800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 27724 KB Output is correct
2 Correct 18 ms 27828 KB Output is correct
3 Correct 20 ms 28020 KB Output is correct
4 Correct 21 ms 28092 KB Output is correct
5 Correct 19 ms 27980 KB Output is correct
6 Correct 20 ms 28104 KB Output is correct
7 Correct 19 ms 27980 KB Output is correct
8 Correct 16 ms 27908 KB Output is correct
9 Correct 15 ms 27836 KB Output is correct
10 Correct 16 ms 27800 KB Output is correct
11 Correct 24 ms 28032 KB Output is correct
12 Correct 19 ms 28136 KB Output is correct
13 Correct 17 ms 27828 KB Output is correct
14 Correct 20 ms 28024 KB Output is correct
15 Correct 15 ms 27724 KB Output is correct
16 Correct 19 ms 28108 KB Output is correct
17 Correct 15 ms 27724 KB Output is correct
18 Correct 19 ms 27980 KB Output is correct
19 Correct 16 ms 27888 KB Output is correct
20 Correct 23 ms 27980 KB Output is correct
21 Correct 18 ms 27980 KB Output is correct
22 Correct 18 ms 27804 KB Output is correct
23 Correct 21 ms 28036 KB Output is correct
24 Correct 17 ms 27852 KB Output is correct
25 Correct 20 ms 28048 KB Output is correct
26 Correct 19 ms 28060 KB Output is correct
27 Correct 19 ms 28056 KB Output is correct
28 Correct 19 ms 27968 KB Output is correct
29 Correct 20 ms 27988 KB Output is correct
30 Correct 20 ms 28032 KB Output is correct
31 Correct 20 ms 27948 KB Output is correct
32 Correct 20 ms 28004 KB Output is correct
33 Correct 21 ms 27980 KB Output is correct
34 Correct 20 ms 28052 KB Output is correct
35 Correct 18 ms 27948 KB Output is correct
36 Correct 19 ms 27876 KB Output is correct
37 Correct 19 ms 27956 KB Output is correct
38 Correct 20 ms 27852 KB Output is correct
39 Correct 21 ms 27852 KB Output is correct
40 Correct 23 ms 27984 KB Output is correct
41 Correct 17 ms 27852 KB Output is correct
42 Correct 22 ms 28040 KB Output is correct
43 Correct 22 ms 28088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 27904 KB Output is correct
2 Correct 16 ms 27816 KB Output is correct
3 Correct 15 ms 27852 KB Output is correct
4 Correct 15 ms 27840 KB Output is correct
5 Correct 17 ms 27780 KB Output is correct
6 Correct 17 ms 27884 KB Output is correct
7 Correct 16 ms 27748 KB Output is correct
8 Correct 15 ms 27744 KB Output is correct
9 Correct 16 ms 27736 KB Output is correct
10 Correct 16 ms 27752 KB Output is correct
11 Correct 169 ms 32156 KB Output is correct
12 Correct 20 ms 27724 KB Output is correct
13 Correct 201 ms 34836 KB Output is correct
14 Correct 16 ms 27752 KB Output is correct
15 Correct 166 ms 34904 KB Output is correct
16 Correct 169 ms 34856 KB Output is correct
17 Correct 178 ms 34804 KB Output is correct
18 Correct 169 ms 34788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 27724 KB Output is correct
2 Correct 18 ms 27828 KB Output is correct
3 Correct 20 ms 28020 KB Output is correct
4 Correct 21 ms 28092 KB Output is correct
5 Correct 19 ms 27980 KB Output is correct
6 Correct 20 ms 28104 KB Output is correct
7 Correct 19 ms 27980 KB Output is correct
8 Correct 16 ms 27908 KB Output is correct
9 Correct 15 ms 27836 KB Output is correct
10 Correct 16 ms 27800 KB Output is correct
11 Correct 24 ms 28032 KB Output is correct
12 Correct 19 ms 28136 KB Output is correct
13 Correct 17 ms 27828 KB Output is correct
14 Correct 20 ms 28024 KB Output is correct
15 Correct 15 ms 27724 KB Output is correct
16 Correct 19 ms 28108 KB Output is correct
17 Correct 15 ms 27724 KB Output is correct
18 Correct 19 ms 27980 KB Output is correct
19 Correct 16 ms 27888 KB Output is correct
20 Correct 23 ms 27980 KB Output is correct
21 Correct 18 ms 27980 KB Output is correct
22 Correct 18 ms 27804 KB Output is correct
23 Correct 21 ms 28036 KB Output is correct
24 Correct 17 ms 27852 KB Output is correct
25 Correct 20 ms 28048 KB Output is correct
26 Correct 19 ms 28060 KB Output is correct
27 Correct 19 ms 28056 KB Output is correct
28 Correct 19 ms 27968 KB Output is correct
29 Correct 20 ms 27988 KB Output is correct
30 Correct 20 ms 28032 KB Output is correct
31 Correct 20 ms 27948 KB Output is correct
32 Correct 20 ms 28004 KB Output is correct
33 Correct 21 ms 27980 KB Output is correct
34 Correct 20 ms 28052 KB Output is correct
35 Correct 18 ms 27948 KB Output is correct
36 Correct 19 ms 27876 KB Output is correct
37 Correct 19 ms 27956 KB Output is correct
38 Correct 20 ms 27852 KB Output is correct
39 Correct 21 ms 27852 KB Output is correct
40 Correct 23 ms 27984 KB Output is correct
41 Correct 17 ms 27852 KB Output is correct
42 Correct 22 ms 28040 KB Output is correct
43 Correct 22 ms 28088 KB Output is correct
44 Correct 30 ms 28100 KB Output is correct
45 Correct 15 ms 27832 KB Output is correct
46 Correct 23 ms 28116 KB Output is correct
47 Correct 36 ms 28100 KB Output is correct
48 Correct 22 ms 27980 KB Output is correct
49 Correct 36 ms 28180 KB Output is correct
50 Correct 28 ms 28168 KB Output is correct
51 Correct 39 ms 28324 KB Output is correct
52 Correct 18 ms 27984 KB Output is correct
53 Correct 42 ms 28424 KB Output is correct
54 Correct 48 ms 28404 KB Output is correct
55 Correct 19 ms 28064 KB Output is correct
56 Correct 24 ms 27976 KB Output is correct
57 Correct 17 ms 27852 KB Output is correct
58 Correct 52 ms 28488 KB Output is correct
59 Correct 22 ms 27980 KB Output is correct
60 Correct 21 ms 28092 KB Output is correct
61 Correct 23 ms 27996 KB Output is correct
62 Correct 22 ms 27980 KB Output is correct
63 Correct 28 ms 28108 KB Output is correct
64 Correct 27 ms 28228 KB Output is correct
65 Correct 22 ms 28100 KB Output is correct
66 Correct 22 ms 27972 KB Output is correct
67 Correct 33 ms 28256 KB Output is correct
68 Correct 26 ms 28108 KB Output is correct
69 Correct 22 ms 27980 KB Output is correct
70 Correct 27 ms 28132 KB Output is correct
71 Correct 32 ms 28236 KB Output is correct
72 Correct 31 ms 28108 KB Output is correct
73 Correct 23 ms 28028 KB Output is correct
74 Correct 27 ms 28156 KB Output is correct
75 Correct 31 ms 28172 KB Output is correct
76 Correct 24 ms 28124 KB Output is correct
77 Correct 33 ms 28228 KB Output is correct
78 Correct 19 ms 27980 KB Output is correct
79 Correct 31 ms 27972 KB Output is correct
80 Correct 23 ms 28128 KB Output is correct
81 Correct 32 ms 28260 KB Output is correct
82 Correct 20 ms 27868 KB Output is correct
83 Correct 25 ms 27988 KB Output is correct
84 Correct 31 ms 28292 KB Output is correct
85 Correct 20 ms 27904 KB Output is correct
86 Correct 29 ms 28236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 27724 KB Output is correct
2 Correct 18 ms 27828 KB Output is correct
3 Correct 20 ms 28020 KB Output is correct
4 Correct 21 ms 28092 KB Output is correct
5 Correct 19 ms 27980 KB Output is correct
6 Correct 20 ms 28104 KB Output is correct
7 Correct 19 ms 27980 KB Output is correct
8 Correct 16 ms 27908 KB Output is correct
9 Correct 15 ms 27836 KB Output is correct
10 Correct 16 ms 27800 KB Output is correct
11 Correct 24 ms 28032 KB Output is correct
12 Correct 19 ms 28136 KB Output is correct
13 Correct 17 ms 27828 KB Output is correct
14 Correct 20 ms 28024 KB Output is correct
15 Correct 15 ms 27724 KB Output is correct
16 Correct 19 ms 28108 KB Output is correct
17 Correct 15 ms 27724 KB Output is correct
18 Correct 19 ms 27980 KB Output is correct
19 Correct 16 ms 27888 KB Output is correct
20 Correct 23 ms 27980 KB Output is correct
21 Correct 18 ms 27980 KB Output is correct
22 Correct 18 ms 27804 KB Output is correct
23 Correct 21 ms 28036 KB Output is correct
24 Correct 17 ms 27852 KB Output is correct
25 Correct 20 ms 28048 KB Output is correct
26 Correct 19 ms 28060 KB Output is correct
27 Correct 19 ms 28056 KB Output is correct
28 Correct 19 ms 27968 KB Output is correct
29 Correct 20 ms 27988 KB Output is correct
30 Correct 20 ms 28032 KB Output is correct
31 Correct 20 ms 27948 KB Output is correct
32 Correct 20 ms 28004 KB Output is correct
33 Correct 21 ms 27980 KB Output is correct
34 Correct 20 ms 28052 KB Output is correct
35 Correct 18 ms 27948 KB Output is correct
36 Correct 19 ms 27876 KB Output is correct
37 Correct 19 ms 27956 KB Output is correct
38 Correct 20 ms 27852 KB Output is correct
39 Correct 21 ms 27852 KB Output is correct
40 Correct 23 ms 27984 KB Output is correct
41 Correct 17 ms 27852 KB Output is correct
42 Correct 22 ms 28040 KB Output is correct
43 Correct 22 ms 28088 KB Output is correct
44 Correct 14 ms 27724 KB Output is correct
45 Correct 123 ms 30628 KB Output is correct
46 Correct 83 ms 30912 KB Output is correct
47 Correct 125 ms 32484 KB Output is correct
48 Correct 122 ms 32440 KB Output is correct
49 Correct 54 ms 30912 KB Output is correct
50 Correct 138 ms 33020 KB Output is correct
51 Correct 169 ms 32464 KB Output is correct
52 Correct 54 ms 30780 KB Output is correct
53 Correct 53 ms 30784 KB Output is correct
54 Correct 23 ms 28360 KB Output is correct
55 Correct 136 ms 32980 KB Output is correct
56 Correct 46 ms 30376 KB Output is correct
57 Correct 55 ms 30788 KB Output is correct
58 Correct 72 ms 30780 KB Output is correct
59 Correct 40 ms 30276 KB Output is correct
60 Correct 41 ms 30280 KB Output is correct
61 Correct 79 ms 30764 KB Output is correct
62 Correct 75 ms 30572 KB Output is correct
63 Correct 96 ms 31272 KB Output is correct
64 Correct 40 ms 30276 KB Output is correct
65 Correct 97 ms 31672 KB Output is correct
66 Correct 59 ms 30568 KB Output is correct
67 Correct 85 ms 31188 KB Output is correct
68 Correct 122 ms 31540 KB Output is correct
69 Correct 102 ms 31700 KB Output is correct
70 Correct 57 ms 30496 KB Output is correct
71 Correct 94 ms 31532 KB Output is correct
72 Correct 79 ms 31048 KB Output is correct
73 Correct 115 ms 31900 KB Output is correct
74 Correct 58 ms 30492 KB Output is correct
75 Correct 54 ms 29632 KB Output is correct
76 Correct 78 ms 31140 KB Output is correct
77 Correct 107 ms 31852 KB Output is correct
78 Correct 60 ms 29892 KB Output is correct
79 Correct 53 ms 29508 KB Output is correct
80 Correct 31 ms 28740 KB Output is correct
81 Correct 66 ms 29808 KB Output is correct
82 Correct 87 ms 31032 KB Output is correct
83 Correct 30 ms 28740 KB Output is correct
84 Correct 88 ms 31052 KB Output is correct