Submission #1042619

# Submission time Handle Problem Language Result Execution time Memory
1042619 2024-08-03T08:34:46 Z DorostWef Stations (IOI20_stations) C++17
100 / 100
532 ms 1208 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1005;
int a[N];
vector <int> g[N];

int dfs (int v, int p, int l, int h) {
	if (h) {
		a[v] = l;
		l++;
	}
	int x = 0;
	for (int u : g[v]) {
		if (u != p) {
			int w = dfs (u, v, l, 1 - h);
			l += w;
			x += w;
		}
	}
	if (!h) {
		a[v] = l;
		l++;
	}
	return x + 1;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	for (int i = 0; i <= n; i++)
		g[i].clear();
	int m = (int)u.size();
	for (int i = 0; i < m; i++) {
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	dfs (0, 0, 0, 0);
	vector <int> labels;
	for (int i = 0; i < n; i++) {
		labels.push_back (a[i]);
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if (c.size() == 1)
		return c[0];
	int w = 1;
	if (s > c[0]) {
		s = -s;
		t = -t;
		for (int i = 0; i < (int)c.size(); i++)
			c[i] = -c[i];
		w = -1;
	}
	sort (c.begin(), c.end());
	int p = N;
	if (s != 0) {
		p = c.back();
		c.pop_back();
	}
	int ft = c.back();
	if (t >= s && t <= ft) {
		for (int x : c) {
			if (x >= t)
				return x * w;
		}
	} else {
		return p * w;
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:72:1: warning: control reaches end of non-void function [-Wreturn-type]
   72 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 287 ms 684 KB Output is correct
2 Correct 283 ms 940 KB Output is correct
3 Correct 510 ms 684 KB Output is correct
4 Correct 397 ms 688 KB Output is correct
5 Correct 303 ms 684 KB Output is correct
6 Correct 238 ms 684 KB Output is correct
7 Correct 249 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 249 ms 684 KB Output is correct
2 Correct 338 ms 684 KB Output is correct
3 Correct 526 ms 684 KB Output is correct
4 Correct 387 ms 684 KB Output is correct
5 Correct 367 ms 684 KB Output is correct
6 Correct 255 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 330 ms 940 KB Output is correct
2 Correct 285 ms 688 KB Output is correct
3 Correct 517 ms 684 KB Output is correct
4 Correct 374 ms 684 KB Output is correct
5 Correct 327 ms 684 KB Output is correct
6 Correct 260 ms 684 KB Output is correct
7 Correct 250 ms 940 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 1 ms 776 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 337 ms 684 KB Output is correct
12 Correct 287 ms 940 KB Output is correct
13 Correct 268 ms 788 KB Output is correct
14 Correct 236 ms 684 KB Output is correct
15 Correct 21 ms 768 KB Output is correct
16 Correct 27 ms 716 KB Output is correct
17 Correct 58 ms 756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 532 ms 684 KB Output is correct
2 Correct 363 ms 684 KB Output is correct
3 Correct 355 ms 684 KB Output is correct
4 Correct 1 ms 776 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 329 ms 796 KB Output is correct
8 Correct 513 ms 684 KB Output is correct
9 Correct 388 ms 684 KB Output is correct
10 Correct 400 ms 684 KB Output is correct
11 Correct 3 ms 776 KB Output is correct
12 Correct 2 ms 776 KB Output is correct
13 Correct 1 ms 776 KB Output is correct
14 Correct 2 ms 776 KB Output is correct
15 Correct 0 ms 768 KB Output is correct
16 Correct 265 ms 684 KB Output is correct
17 Correct 324 ms 684 KB Output is correct
18 Correct 280 ms 684 KB Output is correct
19 Correct 272 ms 684 KB Output is correct
20 Correct 308 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 305 ms 688 KB Output is correct
2 Correct 266 ms 688 KB Output is correct
3 Correct 513 ms 684 KB Output is correct
4 Correct 410 ms 684 KB Output is correct
5 Correct 321 ms 688 KB Output is correct
6 Correct 257 ms 688 KB Output is correct
7 Correct 254 ms 684 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 1 ms 776 KB Output is correct
10 Correct 0 ms 764 KB Output is correct
11 Correct 284 ms 684 KB Output is correct
12 Correct 297 ms 684 KB Output is correct
13 Correct 519 ms 684 KB Output is correct
14 Correct 429 ms 684 KB Output is correct
15 Correct 351 ms 684 KB Output is correct
16 Correct 255 ms 684 KB Output is correct
17 Correct 316 ms 684 KB Output is correct
18 Correct 278 ms 792 KB Output is correct
19 Correct 297 ms 784 KB Output is correct
20 Correct 259 ms 684 KB Output is correct
21 Correct 30 ms 764 KB Output is correct
22 Correct 42 ms 1024 KB Output is correct
23 Correct 49 ms 684 KB Output is correct
24 Correct 2 ms 768 KB Output is correct
25 Correct 3 ms 776 KB Output is correct
26 Correct 1 ms 772 KB Output is correct
27 Correct 1 ms 768 KB Output is correct
28 Correct 1 ms 776 KB Output is correct
29 Correct 277 ms 688 KB Output is correct
30 Correct 327 ms 684 KB Output is correct
31 Correct 298 ms 684 KB Output is correct
32 Correct 288 ms 684 KB Output is correct
33 Correct 295 ms 684 KB Output is correct
34 Correct 201 ms 688 KB Output is correct
35 Correct 206 ms 1208 KB Output is correct
36 Correct 257 ms 932 KB Output is correct
37 Correct 267 ms 684 KB Output is correct
38 Correct 235 ms 932 KB Output is correct
39 Correct 258 ms 684 KB Output is correct
40 Correct 304 ms 808 KB Output is correct
41 Correct 256 ms 1048 KB Output is correct
42 Correct 37 ms 764 KB Output is correct
43 Correct 60 ms 768 KB Output is correct
44 Correct 76 ms 736 KB Output is correct
45 Correct 100 ms 704 KB Output is correct
46 Correct 151 ms 684 KB Output is correct
47 Correct 176 ms 940 KB Output is correct
48 Correct 24 ms 764 KB Output is correct
49 Correct 26 ms 772 KB Output is correct