# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
292809 | 2020-09-07T13:41:17 Z | 반딧불(#5810) | ROI16_sending (ROI16_sending) | C++17 | 5000 ms | 77304 KB |
#include <bits/stdc++.h> #define LIM 18 using namespace std; typedef long long ll; typedef pair<int, int> pi; int n, k; int par[200002], depth[200002]; vector<int> link[200002]; set<int> st[200002]; int ans = -1, ansX, ansY; void dfs(int x){ for(auto &y: link[x]){ if(y == par[x]) continue; depth[y] = depth[x]+1; dfs(y); } } int main(){ scanf("%d %d", &n, &k); for(int i=2; i<=n; i++){ scanf("%d", &par[i]); link[i].push_back(par[i]); link[par[i]].push_back(i); } dfs(1); for(int i=1; i<=k; i++){ int x, y; scanf("%d %d", &x, &y); if(depth[x] > depth[y]) swap(x, y); while(depth[x] < depth[y]) st[i].insert(y), y = par[y]; while(x != y) st[i].insert(x), st[i].insert(y), x = par[x], y = par[y]; } for(int i=1; i<=k; i++){ for(int j=i+1; j<=k; j++){ int cnt = 0; for(auto it = st[i].begin(), it2 = st[j].begin(); it != st[i].end() && it2 != st[j].end(); ){ if(*it == *it2) cnt++, ++it, ++it2; else if(*it < *it2) ++it; else ++it2; } if(ans < cnt){ ans = cnt, ansX = i, ansY = j; } } } printf("%d\n%d %d", ans, ansX, ansY); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 14464 KB | Output is correct |
2 | Correct | 10 ms | 14464 KB | Output is correct |
3 | Correct | 10 ms | 14464 KB | Output is correct |
4 | Correct | 10 ms | 14464 KB | Output is correct |
5 | Correct | 10 ms | 14464 KB | Output is correct |
6 | Correct | 11 ms | 14464 KB | Output is correct |
7 | Correct | 11 ms | 14464 KB | Output is correct |
8 | Correct | 13 ms | 14592 KB | Output is correct |
9 | Correct | 13 ms | 14592 KB | Output is correct |
10 | Correct | 11 ms | 14464 KB | Output is correct |
11 | Correct | 11 ms | 14456 KB | Output is correct |
12 | Correct | 12 ms | 14592 KB | Output is correct |
13 | Correct | 11 ms | 14464 KB | Output is correct |
14 | Correct | 11 ms | 14464 KB | Output is correct |
15 | Correct | 15 ms | 14720 KB | Output is correct |
16 | Correct | 11 ms | 14464 KB | Output is correct |
17 | Correct | 11 ms | 14464 KB | Output is correct |
18 | Correct | 12 ms | 14592 KB | Output is correct |
19 | Correct | 12 ms | 14464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 14464 KB | Output is correct |
2 | Correct | 10 ms | 14464 KB | Output is correct |
3 | Correct | 10 ms | 14464 KB | Output is correct |
4 | Correct | 10 ms | 14464 KB | Output is correct |
5 | Correct | 10 ms | 14464 KB | Output is correct |
6 | Correct | 11 ms | 14464 KB | Output is correct |
7 | Correct | 11 ms | 14464 KB | Output is correct |
8 | Correct | 13 ms | 14592 KB | Output is correct |
9 | Correct | 13 ms | 14592 KB | Output is correct |
10 | Correct | 11 ms | 14464 KB | Output is correct |
11 | Correct | 11 ms | 14456 KB | Output is correct |
12 | Correct | 12 ms | 14592 KB | Output is correct |
13 | Correct | 11 ms | 14464 KB | Output is correct |
14 | Correct | 11 ms | 14464 KB | Output is correct |
15 | Correct | 15 ms | 14720 KB | Output is correct |
16 | Correct | 11 ms | 14464 KB | Output is correct |
17 | Correct | 11 ms | 14464 KB | Output is correct |
18 | Correct | 12 ms | 14592 KB | Output is correct |
19 | Correct | 12 ms | 14464 KB | Output is correct |
20 | Correct | 185 ms | 15300 KB | Output is correct |
21 | Correct | 402 ms | 15992 KB | Output is correct |
22 | Execution timed out | 5062 ms | 77304 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 14464 KB | Output is correct |
2 | Correct | 10 ms | 14464 KB | Output is correct |
3 | Correct | 10 ms | 14464 KB | Output is correct |
4 | Correct | 10 ms | 14464 KB | Output is correct |
5 | Correct | 10 ms | 14464 KB | Output is correct |
6 | Correct | 11 ms | 14464 KB | Output is correct |
7 | Correct | 11 ms | 14464 KB | Output is correct |
8 | Correct | 13 ms | 14592 KB | Output is correct |
9 | Correct | 13 ms | 14592 KB | Output is correct |
10 | Correct | 11 ms | 14464 KB | Output is correct |
11 | Correct | 11 ms | 14456 KB | Output is correct |
12 | Correct | 12 ms | 14592 KB | Output is correct |
13 | Correct | 11 ms | 14464 KB | Output is correct |
14 | Correct | 11 ms | 14464 KB | Output is correct |
15 | Correct | 15 ms | 14720 KB | Output is correct |
16 | Correct | 11 ms | 14464 KB | Output is correct |
17 | Correct | 11 ms | 14464 KB | Output is correct |
18 | Correct | 12 ms | 14592 KB | Output is correct |
19 | Correct | 12 ms | 14464 KB | Output is correct |
20 | Correct | 185 ms | 15300 KB | Output is correct |
21 | Correct | 402 ms | 15992 KB | Output is correct |
22 | Execution timed out | 5062 ms | 77304 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 14464 KB | Output is correct |
2 | Correct | 10 ms | 14464 KB | Output is correct |
3 | Correct | 10 ms | 14464 KB | Output is correct |
4 | Correct | 10 ms | 14464 KB | Output is correct |
5 | Correct | 10 ms | 14464 KB | Output is correct |
6 | Correct | 11 ms | 14464 KB | Output is correct |
7 | Correct | 11 ms | 14464 KB | Output is correct |
8 | Correct | 13 ms | 14592 KB | Output is correct |
9 | Correct | 13 ms | 14592 KB | Output is correct |
10 | Correct | 11 ms | 14464 KB | Output is correct |
11 | Correct | 11 ms | 14456 KB | Output is correct |
12 | Correct | 12 ms | 14592 KB | Output is correct |
13 | Correct | 11 ms | 14464 KB | Output is correct |
14 | Correct | 11 ms | 14464 KB | Output is correct |
15 | Correct | 15 ms | 14720 KB | Output is correct |
16 | Correct | 11 ms | 14464 KB | Output is correct |
17 | Correct | 11 ms | 14464 KB | Output is correct |
18 | Correct | 12 ms | 14592 KB | Output is correct |
19 | Correct | 12 ms | 14464 KB | Output is correct |
20 | Correct | 185 ms | 15300 KB | Output is correct |
21 | Correct | 402 ms | 15992 KB | Output is correct |
22 | Execution timed out | 5062 ms | 77304 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5061 ms | 65320 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5098 ms | 33316 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 14464 KB | Output is correct |
2 | Correct | 10 ms | 14464 KB | Output is correct |
3 | Correct | 10 ms | 14464 KB | Output is correct |
4 | Correct | 10 ms | 14464 KB | Output is correct |
5 | Correct | 10 ms | 14464 KB | Output is correct |
6 | Correct | 11 ms | 14464 KB | Output is correct |
7 | Correct | 11 ms | 14464 KB | Output is correct |
8 | Correct | 13 ms | 14592 KB | Output is correct |
9 | Correct | 13 ms | 14592 KB | Output is correct |
10 | Correct | 11 ms | 14464 KB | Output is correct |
11 | Correct | 11 ms | 14456 KB | Output is correct |
12 | Correct | 12 ms | 14592 KB | Output is correct |
13 | Correct | 11 ms | 14464 KB | Output is correct |
14 | Correct | 11 ms | 14464 KB | Output is correct |
15 | Correct | 15 ms | 14720 KB | Output is correct |
16 | Correct | 11 ms | 14464 KB | Output is correct |
17 | Correct | 11 ms | 14464 KB | Output is correct |
18 | Correct | 12 ms | 14592 KB | Output is correct |
19 | Correct | 12 ms | 14464 KB | Output is correct |
20 | Correct | 185 ms | 15300 KB | Output is correct |
21 | Correct | 402 ms | 15992 KB | Output is correct |
22 | Execution timed out | 5062 ms | 77304 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 14464 KB | Output is correct |
2 | Correct | 10 ms | 14464 KB | Output is correct |
3 | Correct | 10 ms | 14464 KB | Output is correct |
4 | Correct | 10 ms | 14464 KB | Output is correct |
5 | Correct | 10 ms | 14464 KB | Output is correct |
6 | Correct | 11 ms | 14464 KB | Output is correct |
7 | Correct | 11 ms | 14464 KB | Output is correct |
8 | Correct | 13 ms | 14592 KB | Output is correct |
9 | Correct | 13 ms | 14592 KB | Output is correct |
10 | Correct | 11 ms | 14464 KB | Output is correct |
11 | Correct | 11 ms | 14456 KB | Output is correct |
12 | Correct | 12 ms | 14592 KB | Output is correct |
13 | Correct | 11 ms | 14464 KB | Output is correct |
14 | Correct | 11 ms | 14464 KB | Output is correct |
15 | Correct | 15 ms | 14720 KB | Output is correct |
16 | Correct | 11 ms | 14464 KB | Output is correct |
17 | Correct | 11 ms | 14464 KB | Output is correct |
18 | Correct | 12 ms | 14592 KB | Output is correct |
19 | Correct | 12 ms | 14464 KB | Output is correct |
20 | Correct | 185 ms | 15300 KB | Output is correct |
21 | Correct | 402 ms | 15992 KB | Output is correct |
22 | Execution timed out | 5062 ms | 77304 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |