# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
292841 | 2020-09-07T14:09:45 Z | 임성재(#5807) | 서류 전달 (ROI16_sending) | C++17 | 650 ms | 524292 KB |
#include<bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(false); cin.tie(0); #define fi first #define se second #define em emplace #define eb emplace_back #define mp make_pair #define all(v) (v).begin(), (v).end() typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const int inf = 1e9; const ll INF = 1e18; int n, q; int p[200010]; int d[200010]; vector<int> g[200010]; vector<pii> v; int main() { fast; cin >> n >> q; for(int i=2; i<=n; i++) { cin >> p[i]; d[i] = d[p[i]] + 1; } for(int i=1; i<=q; i++) { int u, v; cin >> u >> v; while(u != v) { if(d[u] > d[v]) swap(u, v); g[v].eb(i); v = p[v]; } } for(int i=2; i<=n; i++) { sort(all(g[i])); for(int j=0; j<g[i].size(); j++) { for(int k=j+1; k<g[i].size(); k++) { v.eb(g[i][j], g[i][k]); } } } sort(all(v)); int ans = 0; pii mxi = mp(1, 2); for(int i=0; i<v.size(); ) { int j = i; while(j < v.size() && v[i] == v[j]) j++; if(j - i > ans) { ans = j - i; mxi = v[i]; } i = j; } cout << ans << "\n"; cout << mxi.fi << " " << mxi.se; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 4 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 5 ms | 5120 KB | Output is correct |
7 | Correct | 5 ms | 5248 KB | Output is correct |
8 | Correct | 9 ms | 6272 KB | Output is correct |
9 | Correct | 10 ms | 6272 KB | Output is correct |
10 | Correct | 7 ms | 5764 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 9 ms | 6272 KB | Output is correct |
13 | Correct | 4 ms | 5120 KB | Output is correct |
14 | Correct | 5 ms | 5120 KB | Output is correct |
15 | Correct | 30 ms | 9328 KB | Output is correct |
16 | Correct | 6 ms | 5504 KB | Output is correct |
17 | Correct | 8 ms | 5764 KB | Output is correct |
18 | Correct | 8 ms | 5764 KB | Output is correct |
19 | Correct | 6 ms | 5760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 4 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 5 ms | 5120 KB | Output is correct |
7 | Correct | 5 ms | 5248 KB | Output is correct |
8 | Correct | 9 ms | 6272 KB | Output is correct |
9 | Correct | 10 ms | 6272 KB | Output is correct |
10 | Correct | 7 ms | 5764 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 9 ms | 6272 KB | Output is correct |
13 | Correct | 4 ms | 5120 KB | Output is correct |
14 | Correct | 5 ms | 5120 KB | Output is correct |
15 | Correct | 30 ms | 9328 KB | Output is correct |
16 | Correct | 6 ms | 5504 KB | Output is correct |
17 | Correct | 8 ms | 5764 KB | Output is correct |
18 | Correct | 8 ms | 5764 KB | Output is correct |
19 | Correct | 6 ms | 5760 KB | Output is correct |
20 | Correct | 69 ms | 13552 KB | Output is correct |
21 | Correct | 163 ms | 21856 KB | Output is correct |
22 | Runtime error | 608 ms | 524292 KB | Execution killed with signal 9 |
23 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 4 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 5 ms | 5120 KB | Output is correct |
7 | Correct | 5 ms | 5248 KB | Output is correct |
8 | Correct | 9 ms | 6272 KB | Output is correct |
9 | Correct | 10 ms | 6272 KB | Output is correct |
10 | Correct | 7 ms | 5764 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 9 ms | 6272 KB | Output is correct |
13 | Correct | 4 ms | 5120 KB | Output is correct |
14 | Correct | 5 ms | 5120 KB | Output is correct |
15 | Correct | 30 ms | 9328 KB | Output is correct |
16 | Correct | 6 ms | 5504 KB | Output is correct |
17 | Correct | 8 ms | 5764 KB | Output is correct |
18 | Correct | 8 ms | 5764 KB | Output is correct |
19 | Correct | 6 ms | 5760 KB | Output is correct |
20 | Correct | 69 ms | 13552 KB | Output is correct |
21 | Correct | 163 ms | 21856 KB | Output is correct |
22 | Runtime error | 608 ms | 524292 KB | Execution killed with signal 9 |
23 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 4 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 5 ms | 5120 KB | Output is correct |
7 | Correct | 5 ms | 5248 KB | Output is correct |
8 | Correct | 9 ms | 6272 KB | Output is correct |
9 | Correct | 10 ms | 6272 KB | Output is correct |
10 | Correct | 7 ms | 5764 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 9 ms | 6272 KB | Output is correct |
13 | Correct | 4 ms | 5120 KB | Output is correct |
14 | Correct | 5 ms | 5120 KB | Output is correct |
15 | Correct | 30 ms | 9328 KB | Output is correct |
16 | Correct | 6 ms | 5504 KB | Output is correct |
17 | Correct | 8 ms | 5764 KB | Output is correct |
18 | Correct | 8 ms | 5764 KB | Output is correct |
19 | Correct | 6 ms | 5760 KB | Output is correct |
20 | Correct | 69 ms | 13552 KB | Output is correct |
21 | Correct | 163 ms | 21856 KB | Output is correct |
22 | Runtime error | 608 ms | 524292 KB | Execution killed with signal 9 |
23 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 650 ms | 524292 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 629 ms | 524292 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 4 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 5 ms | 5120 KB | Output is correct |
7 | Correct | 5 ms | 5248 KB | Output is correct |
8 | Correct | 9 ms | 6272 KB | Output is correct |
9 | Correct | 10 ms | 6272 KB | Output is correct |
10 | Correct | 7 ms | 5764 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 9 ms | 6272 KB | Output is correct |
13 | Correct | 4 ms | 5120 KB | Output is correct |
14 | Correct | 5 ms | 5120 KB | Output is correct |
15 | Correct | 30 ms | 9328 KB | Output is correct |
16 | Correct | 6 ms | 5504 KB | Output is correct |
17 | Correct | 8 ms | 5764 KB | Output is correct |
18 | Correct | 8 ms | 5764 KB | Output is correct |
19 | Correct | 6 ms | 5760 KB | Output is correct |
20 | Correct | 69 ms | 13552 KB | Output is correct |
21 | Correct | 163 ms | 21856 KB | Output is correct |
22 | Runtime error | 608 ms | 524292 KB | Execution killed with signal 9 |
23 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 4 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 5 ms | 5120 KB | Output is correct |
7 | Correct | 5 ms | 5248 KB | Output is correct |
8 | Correct | 9 ms | 6272 KB | Output is correct |
9 | Correct | 10 ms | 6272 KB | Output is correct |
10 | Correct | 7 ms | 5764 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 9 ms | 6272 KB | Output is correct |
13 | Correct | 4 ms | 5120 KB | Output is correct |
14 | Correct | 5 ms | 5120 KB | Output is correct |
15 | Correct | 30 ms | 9328 KB | Output is correct |
16 | Correct | 6 ms | 5504 KB | Output is correct |
17 | Correct | 8 ms | 5764 KB | Output is correct |
18 | Correct | 8 ms | 5764 KB | Output is correct |
19 | Correct | 6 ms | 5760 KB | Output is correct |
20 | Correct | 69 ms | 13552 KB | Output is correct |
21 | Correct | 163 ms | 21856 KB | Output is correct |
22 | Runtime error | 608 ms | 524292 KB | Execution killed with signal 9 |
23 | Halted | 0 ms | 0 KB | - |