Submission #381712

# Submission time Handle Problem Language Result Execution time Memory
381712 2021-03-25T18:20:25 Z MohamedAhmed04 Political Development (BOI17_politicaldevelopment) C++14
27 / 100
344 ms 309868 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 5e4 + 10 ;

vector<int>v[MAX] ;
int n , k ;

int ans = 0 ;

vector<int>taken ;
bitset<MAX>mark[MAX] ;

bool check(int x)
{
	for(auto &i : taken)
	{
		if(!mark[x][i] || !mark[i][x])
			return false ;
	}
	return true ;
}

void solve(vector<int>&v1 , int idx)
{
	if(idx == v1.size())
	{
		ans = max(ans , (int)(taken.size())) ;
		return ;
	}
	if(check(v1[idx]))
	{
		taken.push_back(v1[idx]) ;
		solve(v1 , idx+1) ;
		taken.pop_back() ;
	}
	solve(v1 , idx+1) ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>k ;
	for(int i = 0 ; i < n ; ++i)
	{
		int sz ;
		cin>>sz ;
		v[i].resize(sz) ;
		for(auto &j : v[i])
		{
			cin>>j ;
			mark[i][j] = 1 ;
		}
	}
	for(int i = 0 ; i < n ; ++i)
	{
		if(v[i].size() < k)
		{
			taken.push_back(i) ;
			solve(v[i] , 0) ;
			taken.pop_back() ;
		}
	}
	return cout<<ans<<"\n" , 0 ;
}		

Compilation message

politicaldevelopment.cpp: In function 'void solve(std::vector<int>&, int)':
politicaldevelopment.cpp:27:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  if(idx == v1.size())
      |     ~~~~^~~~~~~~~~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:59:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   59 |   if(v[i].size() < k)
      |      ~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1516 KB Output is correct
2 Correct 2 ms 1516 KB Output is correct
3 Correct 15 ms 22380 KB Output is correct
4 Correct 15 ms 21740 KB Output is correct
5 Correct 14 ms 21740 KB Output is correct
6 Correct 14 ms 21740 KB Output is correct
7 Correct 14 ms 21740 KB Output is correct
8 Correct 3 ms 1516 KB Output is correct
9 Correct 2 ms 1516 KB Output is correct
10 Correct 2 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1516 KB Output is correct
2 Correct 2 ms 1516 KB Output is correct
3 Correct 15 ms 22380 KB Output is correct
4 Correct 15 ms 21740 KB Output is correct
5 Correct 14 ms 21740 KB Output is correct
6 Correct 14 ms 21740 KB Output is correct
7 Correct 14 ms 21740 KB Output is correct
8 Correct 3 ms 1516 KB Output is correct
9 Correct 2 ms 1516 KB Output is correct
10 Correct 2 ms 1516 KB Output is correct
11 Correct 14 ms 21740 KB Output is correct
12 Correct 15 ms 21732 KB Output is correct
13 Correct 2 ms 1516 KB Output is correct
14 Correct 14 ms 21740 KB Output is correct
15 Correct 2 ms 1516 KB Output is correct
16 Correct 15 ms 21740 KB Output is correct
17 Correct 2 ms 1516 KB Output is correct
18 Correct 14 ms 21740 KB Output is correct
19 Correct 2 ms 1516 KB Output is correct
20 Correct 14 ms 21760 KB Output is correct
21 Correct 14 ms 21740 KB Output is correct
22 Correct 2 ms 1516 KB Output is correct
23 Incorrect 17 ms 22892 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1516 KB Output is correct
2 Correct 2 ms 1644 KB Output is correct
3 Correct 2 ms 1644 KB Output is correct
4 Correct 2 ms 1516 KB Output is correct
5 Correct 2 ms 1644 KB Output is correct
6 Correct 2 ms 1644 KB Output is correct
7 Correct 2 ms 1644 KB Output is correct
8 Correct 2 ms 1644 KB Output is correct
9 Correct 2 ms 1644 KB Output is correct
10 Correct 2 ms 1644 KB Output is correct
11 Correct 336 ms 309868 KB Output is correct
12 Correct 2 ms 1644 KB Output is correct
13 Correct 344 ms 309868 KB Output is correct
14 Correct 2 ms 1644 KB Output is correct
15 Correct 343 ms 309868 KB Output is correct
16 Correct 335 ms 309868 KB Output is correct
17 Correct 332 ms 309868 KB Output is correct
18 Correct 339 ms 309868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1516 KB Output is correct
2 Correct 2 ms 1516 KB Output is correct
3 Correct 15 ms 22380 KB Output is correct
4 Correct 15 ms 21740 KB Output is correct
5 Correct 14 ms 21740 KB Output is correct
6 Correct 14 ms 21740 KB Output is correct
7 Correct 14 ms 21740 KB Output is correct
8 Correct 3 ms 1516 KB Output is correct
9 Correct 2 ms 1516 KB Output is correct
10 Correct 2 ms 1516 KB Output is correct
11 Correct 14 ms 21740 KB Output is correct
12 Correct 15 ms 21732 KB Output is correct
13 Correct 2 ms 1516 KB Output is correct
14 Correct 14 ms 21740 KB Output is correct
15 Correct 2 ms 1516 KB Output is correct
16 Correct 15 ms 21740 KB Output is correct
17 Correct 2 ms 1516 KB Output is correct
18 Correct 14 ms 21740 KB Output is correct
19 Correct 2 ms 1516 KB Output is correct
20 Correct 14 ms 21760 KB Output is correct
21 Correct 14 ms 21740 KB Output is correct
22 Correct 2 ms 1516 KB Output is correct
23 Incorrect 17 ms 22892 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1516 KB Output is correct
2 Correct 2 ms 1516 KB Output is correct
3 Correct 15 ms 22380 KB Output is correct
4 Correct 15 ms 21740 KB Output is correct
5 Correct 14 ms 21740 KB Output is correct
6 Correct 14 ms 21740 KB Output is correct
7 Correct 14 ms 21740 KB Output is correct
8 Correct 3 ms 1516 KB Output is correct
9 Correct 2 ms 1516 KB Output is correct
10 Correct 2 ms 1516 KB Output is correct
11 Correct 14 ms 21740 KB Output is correct
12 Correct 15 ms 21732 KB Output is correct
13 Correct 2 ms 1516 KB Output is correct
14 Correct 14 ms 21740 KB Output is correct
15 Correct 2 ms 1516 KB Output is correct
16 Correct 15 ms 21740 KB Output is correct
17 Correct 2 ms 1516 KB Output is correct
18 Correct 14 ms 21740 KB Output is correct
19 Correct 2 ms 1516 KB Output is correct
20 Correct 14 ms 21760 KB Output is correct
21 Correct 14 ms 21740 KB Output is correct
22 Correct 2 ms 1516 KB Output is correct
23 Incorrect 17 ms 22892 KB Output isn't correct
24 Halted 0 ms 0 KB -