# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
292836 |
2020-09-07T14:06:27 Z |
임성재(#5807) |
서류 전달 (ROI16_sending) |
C++17 |
|
5000 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];
map<int,int> m[50010];
vector<int> g[200010];
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++) {
m[g[i][j]][g[i][k]]++;
}
}
}
int ans = 0;
pii mxi = mp(1, 2);
for(int i=1; i<=q; i++) {
for(auto j : m[i]) {
if(j.se > ans) {
ans = j.se;
mxi = mp(i, j.fi);
}
}
}
cout << ans << "\n";
cout << mxi.fi << " " << mxi.se;
}
Compilation message
sending.cpp: In function 'int main()':
sending.cpp:48:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for(int j=0; j<g[i].size(); j++) {
| ~^~~~~~~~~~~~
sending.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(int k=j+1; k<g[i].size(); k++) {
| ~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
5 ms |
7424 KB |
Output is correct |
4 |
Correct |
5 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7552 KB |
Output is correct |
7 |
Correct |
6 ms |
7552 KB |
Output is correct |
8 |
Correct |
8 ms |
7552 KB |
Output is correct |
9 |
Correct |
8 ms |
7552 KB |
Output is correct |
10 |
Correct |
7 ms |
7552 KB |
Output is correct |
11 |
Correct |
5 ms |
7424 KB |
Output is correct |
12 |
Correct |
8 ms |
7552 KB |
Output is correct |
13 |
Correct |
6 ms |
7424 KB |
Output is correct |
14 |
Correct |
6 ms |
7552 KB |
Output is correct |
15 |
Correct |
13 ms |
7680 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
6 ms |
7424 KB |
Output is correct |
18 |
Correct |
8 ms |
7552 KB |
Output is correct |
19 |
Correct |
8 ms |
7680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
5 ms |
7424 KB |
Output is correct |
4 |
Correct |
5 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7552 KB |
Output is correct |
7 |
Correct |
6 ms |
7552 KB |
Output is correct |
8 |
Correct |
8 ms |
7552 KB |
Output is correct |
9 |
Correct |
8 ms |
7552 KB |
Output is correct |
10 |
Correct |
7 ms |
7552 KB |
Output is correct |
11 |
Correct |
5 ms |
7424 KB |
Output is correct |
12 |
Correct |
8 ms |
7552 KB |
Output is correct |
13 |
Correct |
6 ms |
7424 KB |
Output is correct |
14 |
Correct |
6 ms |
7552 KB |
Output is correct |
15 |
Correct |
13 ms |
7680 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
6 ms |
7424 KB |
Output is correct |
18 |
Correct |
8 ms |
7552 KB |
Output is correct |
19 |
Correct |
8 ms |
7680 KB |
Output is correct |
20 |
Correct |
92 ms |
20772 KB |
Output is correct |
21 |
Correct |
182 ms |
22648 KB |
Output is correct |
22 |
Execution timed out |
5054 ms |
22324 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
5 ms |
7424 KB |
Output is correct |
4 |
Correct |
5 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7552 KB |
Output is correct |
7 |
Correct |
6 ms |
7552 KB |
Output is correct |
8 |
Correct |
8 ms |
7552 KB |
Output is correct |
9 |
Correct |
8 ms |
7552 KB |
Output is correct |
10 |
Correct |
7 ms |
7552 KB |
Output is correct |
11 |
Correct |
5 ms |
7424 KB |
Output is correct |
12 |
Correct |
8 ms |
7552 KB |
Output is correct |
13 |
Correct |
6 ms |
7424 KB |
Output is correct |
14 |
Correct |
6 ms |
7552 KB |
Output is correct |
15 |
Correct |
13 ms |
7680 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
6 ms |
7424 KB |
Output is correct |
18 |
Correct |
8 ms |
7552 KB |
Output is correct |
19 |
Correct |
8 ms |
7680 KB |
Output is correct |
20 |
Correct |
92 ms |
20772 KB |
Output is correct |
21 |
Correct |
182 ms |
22648 KB |
Output is correct |
22 |
Execution timed out |
5054 ms |
22324 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
5 ms |
7424 KB |
Output is correct |
4 |
Correct |
5 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7552 KB |
Output is correct |
7 |
Correct |
6 ms |
7552 KB |
Output is correct |
8 |
Correct |
8 ms |
7552 KB |
Output is correct |
9 |
Correct |
8 ms |
7552 KB |
Output is correct |
10 |
Correct |
7 ms |
7552 KB |
Output is correct |
11 |
Correct |
5 ms |
7424 KB |
Output is correct |
12 |
Correct |
8 ms |
7552 KB |
Output is correct |
13 |
Correct |
6 ms |
7424 KB |
Output is correct |
14 |
Correct |
6 ms |
7552 KB |
Output is correct |
15 |
Correct |
13 ms |
7680 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
6 ms |
7424 KB |
Output is correct |
18 |
Correct |
8 ms |
7552 KB |
Output is correct |
19 |
Correct |
8 ms |
7680 KB |
Output is correct |
20 |
Correct |
92 ms |
20772 KB |
Output is correct |
21 |
Correct |
182 ms |
22648 KB |
Output is correct |
22 |
Execution timed out |
5054 ms |
22324 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1645 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1648 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
5 ms |
7424 KB |
Output is correct |
4 |
Correct |
5 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7552 KB |
Output is correct |
7 |
Correct |
6 ms |
7552 KB |
Output is correct |
8 |
Correct |
8 ms |
7552 KB |
Output is correct |
9 |
Correct |
8 ms |
7552 KB |
Output is correct |
10 |
Correct |
7 ms |
7552 KB |
Output is correct |
11 |
Correct |
5 ms |
7424 KB |
Output is correct |
12 |
Correct |
8 ms |
7552 KB |
Output is correct |
13 |
Correct |
6 ms |
7424 KB |
Output is correct |
14 |
Correct |
6 ms |
7552 KB |
Output is correct |
15 |
Correct |
13 ms |
7680 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
6 ms |
7424 KB |
Output is correct |
18 |
Correct |
8 ms |
7552 KB |
Output is correct |
19 |
Correct |
8 ms |
7680 KB |
Output is correct |
20 |
Correct |
92 ms |
20772 KB |
Output is correct |
21 |
Correct |
182 ms |
22648 KB |
Output is correct |
22 |
Execution timed out |
5054 ms |
22324 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
5 ms |
7424 KB |
Output is correct |
4 |
Correct |
5 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
6 ms |
7552 KB |
Output is correct |
7 |
Correct |
6 ms |
7552 KB |
Output is correct |
8 |
Correct |
8 ms |
7552 KB |
Output is correct |
9 |
Correct |
8 ms |
7552 KB |
Output is correct |
10 |
Correct |
7 ms |
7552 KB |
Output is correct |
11 |
Correct |
5 ms |
7424 KB |
Output is correct |
12 |
Correct |
8 ms |
7552 KB |
Output is correct |
13 |
Correct |
6 ms |
7424 KB |
Output is correct |
14 |
Correct |
6 ms |
7552 KB |
Output is correct |
15 |
Correct |
13 ms |
7680 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
6 ms |
7424 KB |
Output is correct |
18 |
Correct |
8 ms |
7552 KB |
Output is correct |
19 |
Correct |
8 ms |
7680 KB |
Output is correct |
20 |
Correct |
92 ms |
20772 KB |
Output is correct |
21 |
Correct |
182 ms |
22648 KB |
Output is correct |
22 |
Execution timed out |
5054 ms |
22324 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |