Submission #715152

# Submission time Handle Problem Language Result Execution time Memory
715152 2023-03-26T04:58:59 Z vjudge1 Highway Tolls (IOI18_highway) C++17
100 / 100
265 ms 14940 KB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
 
const int mxN=9e4;
int m, d1[mxN], d2[mxN], me;
vector<int> eu, ev, adj[mxN];
vector<array<int, 2>> p1, p2;
long long bc;
 
void bfs(int s, int d[mxN], vector<array<int, 2>> &p) {
	memset(d, 0x3f, 4*mxN);
	d[s]=0;
	p.push_back({s});
	for(int qh=0; qh<p.size(); ++qh) {
		int u=p[qh][0];
		for(int e : adj[u]) {
			int v=eu[e]^ev[e]^u;
			if(d[v]>d[u]+1) {
				d[v]=d[u]+1;
				p.push_back({v, e});
			}
		}
	}
}
 
int solve(int d1[mxN], int d2[mxN], vector<array<int, 2>> p1, vector<array<int, 2>> p2) {
	vector<array<int, 2>> q;
	for(array<int, 2> a : p1)
		if(d1[a[0]]<d2[a[0]])
			q.push_back(a);//, cout << a[0] << " " << a[1] << endl;
	int lb=0, rb=q.size()-1;
	while(lb<rb) {
		int mb=(lb+rb+1)/2;
		vector<int> w(m, 1);
		w[me]=0;
		for(int i=0; i<mb; ++i)
			w[q[i][1]]=0;
		for(array<int, 2> a : p2)
			if(d2[a[0]]<d1[a[0]])
				w[a[1]]=0;
		if(ask(w)>bc)
			lb=mb;
		else
			rb=mb-1;
	}
	return q[lb][0];
}
 
void find_pair(int n, vector<int> u, vector<int> v, int a, int b) {
	eu=u;
	ev=v;
	m=u.size();
	for(int i=0; i<m; ++i) {
		adj[u[i]].push_back(i);
		adj[v[i]].push_back(i);
	}
	bc=ask(vector<int>(m));
	int lb=0, rb=m-1;
	while(lb<rb) {
		int mb=(lb+rb)/2;
		vector<int> w(m);
		fill(w.begin(), w.begin()+mb+1, 1);
		if(ask(w)>bc)
			rb=mb;
		else
			lb=mb+1;
	}
	me=lb;
	//cout << lb << endl;
	bfs(u[me], d1, p1);
	bfs(v[me], d2, p2);
	answer(solve(d1, d2, p1, p2), solve(d2, d1, p2, p1));
}

Compilation message

highway.cpp: In function 'void bfs(int, int*, std::vector<std::array<int, 2> >&)':
highway.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int qh=0; qh<p.size(); ++qh) {
      |                ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3064 KB Output is correct
2 Correct 2 ms 3024 KB Output is correct
3 Correct 2 ms 3064 KB Output is correct
4 Correct 2 ms 3024 KB Output is correct
5 Correct 2 ms 3024 KB Output is correct
6 Correct 2 ms 3024 KB Output is correct
7 Correct 2 ms 3024 KB Output is correct
8 Correct 2 ms 3024 KB Output is correct
9 Correct 2 ms 3024 KB Output is correct
10 Correct 2 ms 3024 KB Output is correct
11 Correct 2 ms 3024 KB Output is correct
12 Correct 2 ms 3024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3120 KB Output is correct
2 Correct 14 ms 4280 KB Output is correct
3 Correct 144 ms 13892 KB Output is correct
4 Correct 172 ms 12760 KB Output is correct
5 Correct 150 ms 12744 KB Output is correct
6 Correct 123 ms 12468 KB Output is correct
7 Correct 134 ms 12832 KB Output is correct
8 Correct 129 ms 12860 KB Output is correct
9 Correct 126 ms 13904 KB Output is correct
10 Correct 164 ms 12748 KB Output is correct
11 Correct 168 ms 13216 KB Output is correct
12 Correct 195 ms 13888 KB Output is correct
13 Correct 136 ms 12684 KB Output is correct
14 Correct 190 ms 13796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 4212 KB Output is correct
2 Correct 26 ms 5360 KB Output is correct
3 Correct 45 ms 6620 KB Output is correct
4 Correct 134 ms 13060 KB Output is correct
5 Correct 92 ms 13072 KB Output is correct
6 Correct 91 ms 13088 KB Output is correct
7 Correct 141 ms 13708 KB Output is correct
8 Correct 112 ms 13064 KB Output is correct
9 Correct 149 ms 13812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3152 KB Output is correct
2 Correct 15 ms 4276 KB Output is correct
3 Correct 90 ms 10740 KB Output is correct
4 Correct 172 ms 12704 KB Output is correct
5 Correct 117 ms 13908 KB Output is correct
6 Correct 132 ms 12464 KB Output is correct
7 Correct 132 ms 13848 KB Output is correct
8 Correct 161 ms 13884 KB Output is correct
9 Correct 140 ms 13956 KB Output is correct
10 Correct 174 ms 13812 KB Output is correct
11 Correct 157 ms 13800 KB Output is correct
12 Correct 165 ms 12876 KB Output is correct
13 Correct 157 ms 13916 KB Output is correct
14 Correct 155 ms 13256 KB Output is correct
15 Correct 166 ms 12616 KB Output is correct
16 Correct 109 ms 12464 KB Output is correct
17 Correct 151 ms 13788 KB Output is correct
18 Correct 142 ms 13768 KB Output is correct
19 Correct 137 ms 13904 KB Output is correct
20 Correct 163 ms 12764 KB Output is correct
21 Correct 107 ms 12644 KB Output is correct
22 Correct 117 ms 14120 KB Output is correct
23 Correct 129 ms 13504 KB Output is correct
24 Correct 158 ms 13524 KB Output is correct
25 Correct 138 ms 13760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 4176 KB Output is correct
2 Correct 24 ms 4400 KB Output is correct
3 Correct 166 ms 13096 KB Output is correct
4 Correct 190 ms 13904 KB Output is correct
5 Correct 175 ms 14208 KB Output is correct
6 Correct 214 ms 14252 KB Output is correct
7 Correct 219 ms 14412 KB Output is correct
8 Correct 224 ms 14544 KB Output is correct
9 Correct 129 ms 10080 KB Output is correct
10 Correct 186 ms 10140 KB Output is correct
11 Correct 184 ms 10956 KB Output is correct
12 Correct 199 ms 13424 KB Output is correct
13 Correct 194 ms 13876 KB Output is correct
14 Correct 220 ms 14396 KB Output is correct
15 Correct 186 ms 14376 KB Output is correct
16 Correct 152 ms 11196 KB Output is correct
17 Correct 119 ms 14212 KB Output is correct
18 Correct 115 ms 13244 KB Output is correct
19 Correct 135 ms 14188 KB Output is correct
20 Correct 123 ms 13252 KB Output is correct
21 Correct 174 ms 14220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 4364 KB Output is correct
2 Correct 20 ms 4480 KB Output is correct
3 Correct 176 ms 13564 KB Output is correct
4 Correct 162 ms 13668 KB Output is correct
5 Correct 173 ms 13676 KB Output is correct
6 Correct 265 ms 14304 KB Output is correct
7 Correct 153 ms 13076 KB Output is correct
8 Correct 182 ms 13400 KB Output is correct
9 Correct 217 ms 13780 KB Output is correct
10 Correct 252 ms 14552 KB Output is correct
11 Correct 228 ms 14508 KB Output is correct
12 Correct 212 ms 14328 KB Output is correct
13 Correct 167 ms 10664 KB Output is correct
14 Correct 123 ms 10444 KB Output is correct
15 Correct 138 ms 10600 KB Output is correct
16 Correct 142 ms 10500 KB Output is correct
17 Correct 137 ms 10520 KB Output is correct
18 Correct 168 ms 10056 KB Output is correct
19 Correct 199 ms 13152 KB Output is correct
20 Correct 201 ms 13756 KB Output is correct
21 Correct 224 ms 14372 KB Output is correct
22 Correct 213 ms 14432 KB Output is correct
23 Correct 183 ms 14188 KB Output is correct
24 Correct 235 ms 14392 KB Output is correct
25 Correct 256 ms 14336 KB Output is correct
26 Correct 200 ms 14328 KB Output is correct
27 Correct 117 ms 14228 KB Output is correct
28 Correct 140 ms 13316 KB Output is correct
29 Correct 101 ms 14328 KB Output is correct
30 Correct 148 ms 14272 KB Output is correct
31 Correct 144 ms 14252 KB Output is correct
32 Correct 146 ms 14224 KB Output is correct
33 Correct 117 ms 13296 KB Output is correct
34 Correct 109 ms 14220 KB Output is correct
35 Correct 103 ms 14292 KB Output is correct
36 Correct 127 ms 13104 KB Output is correct
37 Correct 140 ms 14420 KB Output is correct
38 Correct 120 ms 12856 KB Output is correct
39 Correct 226 ms 14340 KB Output is correct
40 Correct 239 ms 14940 KB Output is correct
41 Correct 180 ms 14040 KB Output is correct
42 Correct 217 ms 14452 KB Output is correct