Submission #486318

# Submission time Handle Problem Language Result Execution time Memory
486318 2021-11-11T08:37:48 Z Koosha_mv Political Development (BOI17_politicaldevelopment) C++14
54 / 100
3000 ms 34860 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;
			}
		}
		//cout<<mask<<" : "<<fb[mask]<<endl;
	}
	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){
	fill(mark,mark+N,-1);
	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++)
......
   60 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:60:2: note: in expansion of macro 'f'
   60 |  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(i,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:63:2: note: in expansion of macro 'f'
   63 |  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++)
......
   65 |   f(j,0,g[u].size()){
      |     ~~~~~~~~~~~~~~~            
politicaldevelopment.cpp:65:3: note: in expansion of macro 'f'
   65 |   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++)
......
   74 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:74:2: note: in expansion of macro 'f'
   74 |  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++)
......
   95 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:95:2: note: in expansion of macro 'f'
   95 |  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++)
......
   98 |   f(j,0,g[u].size()){
      |     ~~~~~~~~~~~~~~~            
politicaldevelopment.cpp:98:3: note: in expansion of macro 'f'
   98 |   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++)
......
  105 |  f(t,0,v.size()){
      |    ~~~~~~~~~~~~                
politicaldevelopment.cpp:105:2: note: in expansion of macro 'f'
  105 |  f(t,0,v.size()){
      |  ^
# Verdict Execution time Memory Grader output
1 Correct 14 ms 27724 KB Output is correct
2 Correct 16 ms 27848 KB Output is correct
3 Correct 533 ms 28064 KB Output is correct
4 Correct 478 ms 28108 KB Output is correct
5 Correct 506 ms 28072 KB Output is correct
6 Correct 472 ms 28160 KB Output is correct
7 Correct 456 ms 28056 KB Output is correct
8 Correct 456 ms 27904 KB Output is correct
9 Correct 14 ms 27724 KB Output is correct
10 Correct 465 ms 27852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 27724 KB Output is correct
2 Correct 16 ms 27848 KB Output is correct
3 Correct 533 ms 28064 KB Output is correct
4 Correct 478 ms 28108 KB Output is correct
5 Correct 506 ms 28072 KB Output is correct
6 Correct 472 ms 28160 KB Output is correct
7 Correct 456 ms 28056 KB Output is correct
8 Correct 456 ms 27904 KB Output is correct
9 Correct 14 ms 27724 KB Output is correct
10 Correct 465 ms 27852 KB Output is correct
11 Correct 466 ms 28076 KB Output is correct
12 Correct 496 ms 28068 KB Output is correct
13 Correct 18 ms 27724 KB Output is correct
14 Correct 463 ms 28220 KB Output is correct
15 Correct 15 ms 27836 KB Output is correct
16 Correct 449 ms 28140 KB Output is correct
17 Correct 15 ms 27724 KB Output is correct
18 Correct 478 ms 28164 KB Output is correct
19 Correct 505 ms 27972 KB Output is correct
20 Correct 451 ms 27980 KB Output is correct
21 Correct 507 ms 28080 KB Output is correct
22 Correct 435 ms 27852 KB Output is correct
23 Correct 479 ms 28124 KB Output is correct
24 Correct 506 ms 27852 KB Output is correct
25 Correct 466 ms 28124 KB Output is correct
26 Correct 527 ms 28116 KB Output is correct
27 Correct 457 ms 28108 KB Output is correct
28 Correct 524 ms 28108 KB Output is correct
29 Correct 442 ms 28032 KB Output is correct
30 Correct 467 ms 28136 KB Output is correct
31 Correct 492 ms 28108 KB Output is correct
32 Correct 502 ms 28136 KB Output is correct
33 Correct 536 ms 28128 KB Output is correct
34 Correct 453 ms 28108 KB Output is correct
35 Correct 253 ms 27980 KB Output is correct
36 Correct 248 ms 27964 KB Output is correct
37 Correct 249 ms 27900 KB Output is correct
38 Correct 129 ms 27932 KB Output is correct
39 Correct 121 ms 27852 KB Output is correct
40 Correct 468 ms 28184 KB Output is correct
41 Correct 130 ms 27936 KB Output is correct
42 Correct 465 ms 28180 KB Output is correct
43 Correct 479 ms 28176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 461 ms 27972 KB Output is correct
2 Correct 17 ms 27852 KB Output is correct
3 Correct 17 ms 27848 KB Output is correct
4 Correct 19 ms 27740 KB Output is correct
5 Correct 21 ms 27724 KB Output is correct
6 Correct 16 ms 27832 KB Output is correct
7 Correct 21 ms 27744 KB Output is correct
8 Correct 20 ms 27756 KB Output is correct
9 Correct 16 ms 27760 KB Output is correct
10 Correct 16 ms 27796 KB Output is correct
11 Execution timed out 3085 ms 34860 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 27724 KB Output is correct
2 Correct 16 ms 27848 KB Output is correct
3 Correct 533 ms 28064 KB Output is correct
4 Correct 478 ms 28108 KB Output is correct
5 Correct 506 ms 28072 KB Output is correct
6 Correct 472 ms 28160 KB Output is correct
7 Correct 456 ms 28056 KB Output is correct
8 Correct 456 ms 27904 KB Output is correct
9 Correct 14 ms 27724 KB Output is correct
10 Correct 465 ms 27852 KB Output is correct
11 Correct 466 ms 28076 KB Output is correct
12 Correct 496 ms 28068 KB Output is correct
13 Correct 18 ms 27724 KB Output is correct
14 Correct 463 ms 28220 KB Output is correct
15 Correct 15 ms 27836 KB Output is correct
16 Correct 449 ms 28140 KB Output is correct
17 Correct 15 ms 27724 KB Output is correct
18 Correct 478 ms 28164 KB Output is correct
19 Correct 505 ms 27972 KB Output is correct
20 Correct 451 ms 27980 KB Output is correct
21 Correct 507 ms 28080 KB Output is correct
22 Correct 435 ms 27852 KB Output is correct
23 Correct 479 ms 28124 KB Output is correct
24 Correct 506 ms 27852 KB Output is correct
25 Correct 466 ms 28124 KB Output is correct
26 Correct 527 ms 28116 KB Output is correct
27 Correct 457 ms 28108 KB Output is correct
28 Correct 524 ms 28108 KB Output is correct
29 Correct 442 ms 28032 KB Output is correct
30 Correct 467 ms 28136 KB Output is correct
31 Correct 492 ms 28108 KB Output is correct
32 Correct 502 ms 28136 KB Output is correct
33 Correct 536 ms 28128 KB Output is correct
34 Correct 453 ms 28108 KB Output is correct
35 Correct 253 ms 27980 KB Output is correct
36 Correct 248 ms 27964 KB Output is correct
37 Correct 249 ms 27900 KB Output is correct
38 Correct 129 ms 27932 KB Output is correct
39 Correct 121 ms 27852 KB Output is correct
40 Correct 468 ms 28184 KB Output is correct
41 Correct 130 ms 27936 KB Output is correct
42 Correct 465 ms 28180 KB Output is correct
43 Correct 479 ms 28176 KB Output is correct
44 Correct 506 ms 28324 KB Output is correct
45 Correct 16 ms 27724 KB Output is correct
46 Correct 565 ms 28192 KB Output is correct
47 Correct 514 ms 28328 KB Output is correct
48 Correct 481 ms 28228 KB Output is correct
49 Correct 483 ms 28388 KB Output is correct
50 Correct 474 ms 28376 KB Output is correct
51 Correct 552 ms 28796 KB Output is correct
52 Correct 514 ms 28128 KB Output is correct
53 Correct 481 ms 28928 KB Output is correct
54 Correct 515 ms 28796 KB Output is correct
55 Correct 501 ms 28256 KB Output is correct
56 Correct 518 ms 28228 KB Output is correct
57 Correct 457 ms 27852 KB Output is correct
58 Correct 525 ms 28932 KB Output is correct
59 Correct 461 ms 28156 KB Output is correct
60 Correct 473 ms 28148 KB Output is correct
61 Correct 495 ms 28144 KB Output is correct
62 Correct 486 ms 28152 KB Output is correct
63 Correct 496 ms 28228 KB Output is correct
64 Correct 549 ms 28308 KB Output is correct
65 Correct 490 ms 28236 KB Output is correct
66 Correct 490 ms 28152 KB Output is correct
67 Correct 494 ms 28464 KB Output is correct
68 Correct 470 ms 28300 KB Output is correct
69 Correct 492 ms 28108 KB Output is correct
70 Correct 492 ms 28340 KB Output is correct
71 Correct 467 ms 28460 KB Output is correct
72 Correct 505 ms 28444 KB Output is correct
73 Correct 469 ms 28228 KB Output is correct
74 Correct 485 ms 28352 KB Output is correct
75 Correct 467 ms 28364 KB Output is correct
76 Correct 477 ms 28240 KB Output is correct
77 Correct 473 ms 28608 KB Output is correct
78 Correct 493 ms 28104 KB Output is correct
79 Correct 247 ms 28228 KB Output is correct
80 Correct 532 ms 28240 KB Output is correct
81 Correct 484 ms 28580 KB Output is correct
82 Correct 148 ms 27908 KB Output is correct
83 Correct 237 ms 28124 KB Output is correct
84 Correct 482 ms 28500 KB Output is correct
85 Correct 120 ms 27852 KB Output is correct
86 Correct 532 ms 28452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 27724 KB Output is correct
2 Correct 16 ms 27848 KB Output is correct
3 Correct 533 ms 28064 KB Output is correct
4 Correct 478 ms 28108 KB Output is correct
5 Correct 506 ms 28072 KB Output is correct
6 Correct 472 ms 28160 KB Output is correct
7 Correct 456 ms 28056 KB Output is correct
8 Correct 456 ms 27904 KB Output is correct
9 Correct 14 ms 27724 KB Output is correct
10 Correct 465 ms 27852 KB Output is correct
11 Correct 466 ms 28076 KB Output is correct
12 Correct 496 ms 28068 KB Output is correct
13 Correct 18 ms 27724 KB Output is correct
14 Correct 463 ms 28220 KB Output is correct
15 Correct 15 ms 27836 KB Output is correct
16 Correct 449 ms 28140 KB Output is correct
17 Correct 15 ms 27724 KB Output is correct
18 Correct 478 ms 28164 KB Output is correct
19 Correct 505 ms 27972 KB Output is correct
20 Correct 451 ms 27980 KB Output is correct
21 Correct 507 ms 28080 KB Output is correct
22 Correct 435 ms 27852 KB Output is correct
23 Correct 479 ms 28124 KB Output is correct
24 Correct 506 ms 27852 KB Output is correct
25 Correct 466 ms 28124 KB Output is correct
26 Correct 527 ms 28116 KB Output is correct
27 Correct 457 ms 28108 KB Output is correct
28 Correct 524 ms 28108 KB Output is correct
29 Correct 442 ms 28032 KB Output is correct
30 Correct 467 ms 28136 KB Output is correct
31 Correct 492 ms 28108 KB Output is correct
32 Correct 502 ms 28136 KB Output is correct
33 Correct 536 ms 28128 KB Output is correct
34 Correct 453 ms 28108 KB Output is correct
35 Correct 253 ms 27980 KB Output is correct
36 Correct 248 ms 27964 KB Output is correct
37 Correct 249 ms 27900 KB Output is correct
38 Correct 129 ms 27932 KB Output is correct
39 Correct 121 ms 27852 KB Output is correct
40 Correct 468 ms 28184 KB Output is correct
41 Correct 130 ms 27936 KB Output is correct
42 Correct 465 ms 28180 KB Output is correct
43 Correct 479 ms 28176 KB Output is correct
44 Correct 15 ms 27724 KB Output is correct
45 Execution timed out 3088 ms 32396 KB Time limit exceeded
46 Halted 0 ms 0 KB -