Submission #854192

# Submission time Handle Problem Language Result Execution time Memory
854192 2023-09-26T10:16:58 Z nnin Stations (IOI20_stations) C++14
100 / 100
507 ms 1556 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;

vector<int> tmp, adj[1005];
int num;

void dfs(int cur, int prev, bool mx) {
	if(!mx)  tmp[cur] = num++;
	for(int next:adj[cur]) {
		if(next==prev) continue;
		dfs(next, cur, !mx);
	}
	if(mx) tmp[cur] = num++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	tmp.resize(n);
	num = 0;
	for(int i=0;i<n;i++) adj[i].clear();
	for(int i=0;i<n-1;i++) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	dfs(0, -1, 0);
	for(int i=0;i<n;i++) labels[i] = tmp[i];
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(s<c[0]) {
		if(t<s) return c[c.size()-1];
		for (int i=0;i<c.size()-1;i++) if(t<=c[i]) return c[i];
		return c[c.size()-1];
	} else {
		if(t>s) return c[0];
		for (int i=c.size()-1;i>=1;i--) if(t>=c[i]) return c[i];
		return c[0];
		
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for (int i=0;i<c.size()-1;i++) if(t<=c[i]) return c[i];
      |                ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 316 ms 1180 KB Output is correct
2 Correct 245 ms 948 KB Output is correct
3 Correct 504 ms 688 KB Output is correct
4 Correct 368 ms 684 KB Output is correct
5 Correct 342 ms 684 KB Output is correct
6 Correct 255 ms 920 KB Output is correct
7 Correct 265 ms 684 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 0 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 267 ms 876 KB Output is correct
2 Correct 320 ms 812 KB Output is correct
3 Correct 502 ms 856 KB Output is correct
4 Correct 379 ms 684 KB Output is correct
5 Correct 322 ms 684 KB Output is correct
6 Correct 255 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 306 ms 1168 KB Output is correct
2 Correct 255 ms 936 KB Output is correct
3 Correct 476 ms 684 KB Output is correct
4 Correct 377 ms 688 KB Output is correct
5 Correct 325 ms 684 KB Output is correct
6 Correct 238 ms 908 KB Output is correct
7 Correct 253 ms 684 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 0 ms 764 KB Output is correct
11 Correct 312 ms 684 KB Output is correct
12 Correct 251 ms 972 KB Output is correct
13 Correct 246 ms 1296 KB Output is correct
14 Correct 239 ms 684 KB Output is correct
15 Correct 28 ms 764 KB Output is correct
16 Correct 44 ms 840 KB Output is correct
17 Correct 62 ms 940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 464 ms 684 KB Output is correct
2 Correct 358 ms 868 KB Output is correct
3 Correct 319 ms 684 KB Output is correct
4 Correct 1 ms 764 KB Output is correct
5 Correct 3 ms 764 KB Output is correct
6 Correct 0 ms 764 KB Output is correct
7 Correct 353 ms 684 KB Output is correct
8 Correct 473 ms 684 KB Output is correct
9 Correct 366 ms 856 KB Output is correct
10 Correct 307 ms 684 KB Output is correct
11 Correct 3 ms 768 KB Output is correct
12 Correct 2 ms 764 KB Output is correct
13 Correct 3 ms 764 KB Output is correct
14 Correct 1 ms 764 KB Output is correct
15 Correct 0 ms 764 KB Output is correct
16 Correct 287 ms 684 KB Output is correct
17 Correct 292 ms 684 KB Output is correct
18 Correct 294 ms 684 KB Output is correct
19 Correct 305 ms 684 KB Output is correct
20 Correct 284 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 320 ms 932 KB Output is correct
2 Correct 243 ms 936 KB Output is correct
3 Correct 506 ms 940 KB Output is correct
4 Correct 374 ms 684 KB Output is correct
5 Correct 327 ms 692 KB Output is correct
6 Correct 249 ms 936 KB Output is correct
7 Correct 265 ms 684 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 2 ms 1016 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 257 ms 880 KB Output is correct
12 Correct 318 ms 840 KB Output is correct
13 Correct 507 ms 884 KB Output is correct
14 Correct 381 ms 684 KB Output is correct
15 Correct 346 ms 688 KB Output is correct
16 Correct 269 ms 684 KB Output is correct
17 Correct 350 ms 684 KB Output is correct
18 Correct 259 ms 1016 KB Output is correct
19 Correct 274 ms 1284 KB Output is correct
20 Correct 264 ms 684 KB Output is correct
21 Correct 35 ms 764 KB Output is correct
22 Correct 47 ms 840 KB Output is correct
23 Correct 63 ms 1376 KB Output is correct
24 Correct 4 ms 764 KB Output is correct
25 Correct 3 ms 792 KB Output is correct
26 Correct 3 ms 764 KB Output is correct
27 Correct 2 ms 764 KB Output is correct
28 Correct 1 ms 764 KB Output is correct
29 Correct 276 ms 940 KB Output is correct
30 Correct 281 ms 684 KB Output is correct
31 Correct 296 ms 684 KB Output is correct
32 Correct 288 ms 684 KB Output is correct
33 Correct 282 ms 684 KB Output is correct
34 Correct 173 ms 920 KB Output is correct
35 Correct 242 ms 1556 KB Output is correct
36 Correct 252 ms 1180 KB Output is correct
37 Correct 275 ms 1152 KB Output is correct
38 Correct 246 ms 1148 KB Output is correct
39 Correct 262 ms 1148 KB Output is correct
40 Correct 251 ms 1160 KB Output is correct
41 Correct 275 ms 1328 KB Output is correct
42 Correct 39 ms 844 KB Output is correct
43 Correct 56 ms 952 KB Output is correct
44 Correct 73 ms 940 KB Output is correct
45 Correct 91 ms 884 KB Output is correct
46 Correct 181 ms 864 KB Output is correct
47 Correct 173 ms 888 KB Output is correct
48 Correct 37 ms 1424 KB Output is correct
49 Correct 28 ms 1176 KB Output is correct