Submission #293019

# Submission time Handle Problem Language Result Execution time Memory
293019 2020-09-07T15:36:26 Z 임성재(#5807) ROI16_sending (ROI16_sending) C++17
29 / 100
466 ms 337400 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 unsigned int ui;
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[100010];
int d[100010];
vector<int> g[100010];
ui v[40000010];
int cnt = 0;

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[cnt++] = g[i][j] + (ui) q * g[i][k];
			}
		}
	}

	sort(v, v + cnt);

	int ans = 0;
	ui mxi = 1 + 2 * q;
	
	for(int i=0; i<cnt; ) {
		int j = i;
		while(j < cnt && v[i] == v[j]) j++;

		if(j - i > ans) {
			ans = j - i;
			mxi = v[i];
		}

		i = j;
	}
	
	cout << ans << "\n";
	cout << (mxi-1) % q + 1 << " " << (mxi-1) / q;
}

Compilation message

sending.cpp: In function 'int main()':
sending.cpp:50:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for(int j=0; j<g[i].size(); j++) {
      |                ~^~~~~~~~~~~~
sending.cpp:51:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |    for(int k=j+1; k<g[i].size(); k++) {
      |                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 7 ms 3072 KB Output is correct
9 Correct 8 ms 3072 KB Output is correct
10 Correct 6 ms 2944 KB Output is correct
11 Correct 2 ms 2688 KB Output is correct
12 Correct 8 ms 3072 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 25 ms 4224 KB Output is correct
16 Correct 4 ms 2816 KB Output is correct
17 Correct 5 ms 2816 KB Output is correct
18 Correct 6 ms 2944 KB Output is correct
19 Correct 4 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 7 ms 3072 KB Output is correct
9 Correct 8 ms 3072 KB Output is correct
10 Correct 6 ms 2944 KB Output is correct
11 Correct 2 ms 2688 KB Output is correct
12 Correct 8 ms 3072 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 25 ms 4224 KB Output is correct
16 Correct 4 ms 2816 KB Output is correct
17 Correct 5 ms 2816 KB Output is correct
18 Correct 6 ms 2944 KB Output is correct
19 Correct 4 ms 2816 KB Output is correct
20 Correct 73 ms 6016 KB Output is correct
21 Correct 166 ms 10232 KB Output is correct
22 Runtime error 403 ms 336096 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 7 ms 3072 KB Output is correct
9 Correct 8 ms 3072 KB Output is correct
10 Correct 6 ms 2944 KB Output is correct
11 Correct 2 ms 2688 KB Output is correct
12 Correct 8 ms 3072 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 25 ms 4224 KB Output is correct
16 Correct 4 ms 2816 KB Output is correct
17 Correct 5 ms 2816 KB Output is correct
18 Correct 6 ms 2944 KB Output is correct
19 Correct 4 ms 2816 KB Output is correct
20 Correct 73 ms 6016 KB Output is correct
21 Correct 166 ms 10232 KB Output is correct
22 Runtime error 403 ms 336096 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 7 ms 3072 KB Output is correct
9 Correct 8 ms 3072 KB Output is correct
10 Correct 6 ms 2944 KB Output is correct
11 Correct 2 ms 2688 KB Output is correct
12 Correct 8 ms 3072 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 25 ms 4224 KB Output is correct
16 Correct 4 ms 2816 KB Output is correct
17 Correct 5 ms 2816 KB Output is correct
18 Correct 6 ms 2944 KB Output is correct
19 Correct 4 ms 2816 KB Output is correct
20 Correct 73 ms 6016 KB Output is correct
21 Correct 166 ms 10232 KB Output is correct
22 Runtime error 403 ms 336096 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 466 ms 337400 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 406 ms 330108 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 7 ms 3072 KB Output is correct
9 Correct 8 ms 3072 KB Output is correct
10 Correct 6 ms 2944 KB Output is correct
11 Correct 2 ms 2688 KB Output is correct
12 Correct 8 ms 3072 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 25 ms 4224 KB Output is correct
16 Correct 4 ms 2816 KB Output is correct
17 Correct 5 ms 2816 KB Output is correct
18 Correct 6 ms 2944 KB Output is correct
19 Correct 4 ms 2816 KB Output is correct
20 Correct 73 ms 6016 KB Output is correct
21 Correct 166 ms 10232 KB Output is correct
22 Runtime error 403 ms 336096 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 7 ms 3072 KB Output is correct
9 Correct 8 ms 3072 KB Output is correct
10 Correct 6 ms 2944 KB Output is correct
11 Correct 2 ms 2688 KB Output is correct
12 Correct 8 ms 3072 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 25 ms 4224 KB Output is correct
16 Correct 4 ms 2816 KB Output is correct
17 Correct 5 ms 2816 KB Output is correct
18 Correct 6 ms 2944 KB Output is correct
19 Correct 4 ms 2816 KB Output is correct
20 Correct 73 ms 6016 KB Output is correct
21 Correct 166 ms 10232 KB Output is correct
22 Runtime error 403 ms 336096 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -