# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472501 | 2021-09-13T16:25:09 Z | yasseenkamel | Political Development (BOI17_politicaldevelopment) | C++14 | 292 ms | 640 KB |
#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(vis[node]){ if(d == min(m,(int)3)){ ans = max(ans,d); } else if(d == 2){ ans = max(ans,d); } return; } if(d >= 3){ return; } //cout << node << " " << d << endl; vis[node] = 1; for(int i = 0 ; i < adj[node].size() ; i ++){ dfs(adj[node][i],d + 1); } } in main(){ cin >> n >> m; if(m == 1){ cout << "1\n"; return 0; } for(int i = 0 ; i < n ; i ++){ int x; cin >> x; while(x --){ int y; cin >> y; adj[i].push_back(y); } } for(int i = 0 ; i < n ; i ++){ memset(vis,0,sizeof vis); dfs(i,0); } cout << ans << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 7 ms | 588 KB | Output is correct |
4 | Correct | 278 ms | 588 KB | Output is correct |
5 | Correct | 272 ms | 596 KB | Output is correct |
6 | Correct | 13 ms | 588 KB | Output is correct |
7 | Correct | 12 ms | 640 KB | Output is correct |
8 | Correct | 2 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 7 ms | 588 KB | Output is correct |
4 | Correct | 278 ms | 588 KB | Output is correct |
5 | Correct | 272 ms | 596 KB | Output is correct |
6 | Correct | 13 ms | 588 KB | Output is correct |
7 | Correct | 12 ms | 640 KB | Output is correct |
8 | Correct | 2 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 332 KB | Output is correct |
11 | Correct | 275 ms | 600 KB | Output is correct |
12 | Incorrect | 292 ms | 564 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 416 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Incorrect | 1 ms | 332 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 7 ms | 588 KB | Output is correct |
4 | Correct | 278 ms | 588 KB | Output is correct |
5 | Correct | 272 ms | 596 KB | Output is correct |
6 | Correct | 13 ms | 588 KB | Output is correct |
7 | Correct | 12 ms | 640 KB | Output is correct |
8 | Correct | 2 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 332 KB | Output is correct |
11 | Correct | 275 ms | 600 KB | Output is correct |
12 | Incorrect | 292 ms | 564 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 7 ms | 588 KB | Output is correct |
4 | Correct | 278 ms | 588 KB | Output is correct |
5 | Correct | 272 ms | 596 KB | Output is correct |
6 | Correct | 13 ms | 588 KB | Output is correct |
7 | Correct | 12 ms | 640 KB | Output is correct |
8 | Correct | 2 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 332 KB | Output is correct |
11 | Correct | 275 ms | 600 KB | Output is correct |
12 | Incorrect | 292 ms | 564 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |