#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
const int nax=5e4+5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<bitset<nax>> adj(nax);
int n,k;
int dfs(int x){
int lst=x;
auto cur=adj[x];
int cnt=0;
while(true){
cnt++;
cur&=adj[lst];
vector<int> tab;
for (int i = cur._Find_first(); (int)tab.size() < 10 && i < n; i=cur._Find_next(i))
{
tab.pb(i);
}
if(tab.size()==0) break;
lst=tab[uniform_int_distribution<int>(0,(int)tab.size()-1)(rng)];
}
return cnt;
}
int main(){
/*#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif*/
cin>>n>>k;
bool test=false;
for (int i = 0; i < n; ++i)
{
int s;
cin>>s;
for (int j = 0; j < s; ++j)
{
int x;
cin>>x;
adj[i][x]=1;
}
}
vector<int> per(n);
for (int i = 0; i < n; ++i)
{
per[i]=i;
}
int ans=1;
for (int i = 0; i < n*5; ++i)
{
if(i%n==0) shuffle(per.begin(),per.end(),rng);
ans=max(ans,dfs(per[i%5]));
}
cout <<ans<<endl;
}
Compilation message
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:35:10: warning: unused variable 'test' [-Wunused-variable]
35 | bool test=false;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
306512 KB |
Output is correct |
2 |
Correct |
38 ms |
306512 KB |
Output is correct |
3 |
Correct |
72 ms |
306612 KB |
Output is correct |
4 |
Correct |
73 ms |
306532 KB |
Output is correct |
5 |
Correct |
70 ms |
306608 KB |
Output is correct |
6 |
Correct |
71 ms |
306600 KB |
Output is correct |
7 |
Correct |
72 ms |
306512 KB |
Output is correct |
8 |
Correct |
55 ms |
306536 KB |
Output is correct |
9 |
Correct |
38 ms |
306436 KB |
Output is correct |
10 |
Incorrect |
54 ms |
306516 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
306512 KB |
Output is correct |
2 |
Correct |
38 ms |
306512 KB |
Output is correct |
3 |
Correct |
72 ms |
306612 KB |
Output is correct |
4 |
Correct |
73 ms |
306532 KB |
Output is correct |
5 |
Correct |
70 ms |
306608 KB |
Output is correct |
6 |
Correct |
71 ms |
306600 KB |
Output is correct |
7 |
Correct |
72 ms |
306512 KB |
Output is correct |
8 |
Correct |
55 ms |
306536 KB |
Output is correct |
9 |
Correct |
38 ms |
306436 KB |
Output is correct |
10 |
Incorrect |
54 ms |
306516 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
306772 KB |
Output is correct |
2 |
Correct |
40 ms |
306512 KB |
Output is correct |
3 |
Correct |
38 ms |
306512 KB |
Output is correct |
4 |
Correct |
38 ms |
306512 KB |
Output is correct |
5 |
Correct |
39 ms |
306516 KB |
Output is correct |
6 |
Correct |
39 ms |
306512 KB |
Output is correct |
7 |
Correct |
39 ms |
306524 KB |
Output is correct |
8 |
Correct |
38 ms |
306516 KB |
Output is correct |
9 |
Correct |
38 ms |
306516 KB |
Output is correct |
10 |
Correct |
41 ms |
306516 KB |
Output is correct |
11 |
Incorrect |
514 ms |
309336 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
306512 KB |
Output is correct |
2 |
Correct |
38 ms |
306512 KB |
Output is correct |
3 |
Correct |
72 ms |
306612 KB |
Output is correct |
4 |
Correct |
73 ms |
306532 KB |
Output is correct |
5 |
Correct |
70 ms |
306608 KB |
Output is correct |
6 |
Correct |
71 ms |
306600 KB |
Output is correct |
7 |
Correct |
72 ms |
306512 KB |
Output is correct |
8 |
Correct |
55 ms |
306536 KB |
Output is correct |
9 |
Correct |
38 ms |
306436 KB |
Output is correct |
10 |
Incorrect |
54 ms |
306516 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
306512 KB |
Output is correct |
2 |
Correct |
38 ms |
306512 KB |
Output is correct |
3 |
Correct |
72 ms |
306612 KB |
Output is correct |
4 |
Correct |
73 ms |
306532 KB |
Output is correct |
5 |
Correct |
70 ms |
306608 KB |
Output is correct |
6 |
Correct |
71 ms |
306600 KB |
Output is correct |
7 |
Correct |
72 ms |
306512 KB |
Output is correct |
8 |
Correct |
55 ms |
306536 KB |
Output is correct |
9 |
Correct |
38 ms |
306436 KB |
Output is correct |
10 |
Incorrect |
54 ms |
306516 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |