# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472485 | yasseenkamel | Political Development (BOI17_politicaldevelopment) | C++14 | 5 ms | 668 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define s second
#define f first
const long double EPS=1e-9;
const int MOD=1e9+7;
const int N=1e6;
int n,m;
vector<int> adj[5005];
bool vis[5005];
int ans = 1;
void dfs(int node,int d){
if(d > 2){
return;
}
if(vis[node]){
if(d == 3){
ans = max(ans,d);
}
else if(d == 2){
ans = max(ans,d);
}
return;
}
vis[node] = 1;
for(int i = 0 ; i < adj[node].size() ; i ++){
dfs(adj[node][i],d + 1);
}
}
in main(){
cin >> n >> m;
for(int i = 0 ; i < n ; i ++){
int x;
cin >> x;
while(x --){
int y;
cin >> y;
adj[x].push_back(y);
}
}
cout << min((int)2,n) << endl;
return 0;
for(int i = 0 ; i < n ; i ++){
memset(vis,0,sizeof vis);
dfs(i,0);
}
cout << ans << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |