/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define gen(arr,n,nxt) generate(arr,arr+n,nxt)
#define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0);
#define EPS 0.00000001
const int mo=1e9+7,INF=1e18;
int nxt(){int x;cin>>x;return x;}
int now=-1;
vector<int>adj[50001];
bool vis[50001];
map<pair<int,int> ,bool>ok;
vector<int>path;
void dfs(int u, int cnt = 1){
if(cnt == now){
cout<<now<<endl;
exit(0);
}
vis[u] = 1;
path.push_back(u);
for(auto v:adj[u]){
if(!vis[v]){
bool iwillgothere = 1;
for(int i=0;i<path.size();i++){
if(ok[{v,path[i]}]||ok[{path[i],v}]);
else iwillgothere&=0;
}
if(iwillgothere)
dfs(v,cnt+1);
}
}
path.pop_back();
}
signed main(){
Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty
//freopen("in.txt","r",stdin);
int n=nxt(),k=nxt();
for(int i=0;i<n;i++){
int sz = nxt();
for(int j=0;j<sz;j++){
int x=nxt()-1;
adj[i].push_back(x);
ok[{i,x}] = 1;
}
}
int ans = -1;
for(ans = k;ans>=1;ans--){
now = ans;
for(int i =0;i<n;i++){
dfs(i);
memset(vis,0,sizeof vis);
}
}
return 0;
}
Compilation message
politicaldevelopment.cpp:21:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
21 | const int mo=1e9+7,INF=1e18;
| ^~~~
politicaldevelopment.cpp: In function 'void dfs(int, int)':
politicaldevelopment.cpp:38:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i=0;i<path.size();i++){
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1488 KB |
Output is correct |
2 |
Correct |
1 ms |
1488 KB |
Output is correct |
3 |
Correct |
6 ms |
2252 KB |
Output is correct |
4 |
Correct |
5 ms |
2268 KB |
Output is correct |
5 |
Correct |
5 ms |
2252 KB |
Output is correct |
6 |
Correct |
5 ms |
2364 KB |
Output is correct |
7 |
Correct |
5 ms |
2252 KB |
Output is correct |
8 |
Correct |
10 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1488 KB |
Output is correct |
2 |
Correct |
1 ms |
1488 KB |
Output is correct |
3 |
Correct |
6 ms |
2252 KB |
Output is correct |
4 |
Correct |
5 ms |
2268 KB |
Output is correct |
5 |
Correct |
5 ms |
2252 KB |
Output is correct |
6 |
Correct |
5 ms |
2364 KB |
Output is correct |
7 |
Correct |
5 ms |
2252 KB |
Output is correct |
8 |
Correct |
10 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1484 KB |
Output is correct |
11 |
Correct |
5 ms |
2252 KB |
Output is correct |
12 |
Correct |
22 ms |
3112 KB |
Output is correct |
13 |
Correct |
1 ms |
1484 KB |
Output is correct |
14 |
Correct |
25 ms |
3004 KB |
Output is correct |
15 |
Incorrect |
1 ms |
1484 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
1484 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1488 KB |
Output is correct |
2 |
Correct |
1 ms |
1488 KB |
Output is correct |
3 |
Correct |
6 ms |
2252 KB |
Output is correct |
4 |
Correct |
5 ms |
2268 KB |
Output is correct |
5 |
Correct |
5 ms |
2252 KB |
Output is correct |
6 |
Correct |
5 ms |
2364 KB |
Output is correct |
7 |
Correct |
5 ms |
2252 KB |
Output is correct |
8 |
Correct |
10 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1484 KB |
Output is correct |
11 |
Correct |
5 ms |
2252 KB |
Output is correct |
12 |
Correct |
22 ms |
3112 KB |
Output is correct |
13 |
Correct |
1 ms |
1484 KB |
Output is correct |
14 |
Correct |
25 ms |
3004 KB |
Output is correct |
15 |
Incorrect |
1 ms |
1484 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1488 KB |
Output is correct |
2 |
Correct |
1 ms |
1488 KB |
Output is correct |
3 |
Correct |
6 ms |
2252 KB |
Output is correct |
4 |
Correct |
5 ms |
2268 KB |
Output is correct |
5 |
Correct |
5 ms |
2252 KB |
Output is correct |
6 |
Correct |
5 ms |
2364 KB |
Output is correct |
7 |
Correct |
5 ms |
2252 KB |
Output is correct |
8 |
Correct |
10 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1484 KB |
Output is correct |
11 |
Correct |
5 ms |
2252 KB |
Output is correct |
12 |
Correct |
22 ms |
3112 KB |
Output is correct |
13 |
Correct |
1 ms |
1484 KB |
Output is correct |
14 |
Correct |
25 ms |
3004 KB |
Output is correct |
15 |
Incorrect |
1 ms |
1484 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |