Submission #311948

# Submission time Handle Problem Language Result Execution time Memory
311948 2020-10-12T03:45:38 Z Eric_hoo Stations (IOI20_stations) C++14
100 / 100
1041 ms 1160 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

vector <int> id; int TOT;
vector <int> from[1010];

void dfs(int x, int last, int dep) {
	if (dep & 1) {
		id[x] = TOT++;
		for (int i = 0; i < from[x].size(); i++) {
			int v = from[x][i];
			if (v == last) continue;
			dfs(v, x, dep + 1);
		}
	} else {
		for (int i = 0; i < from[x].size(); i++) {
			int v = from[x][i];
			if (v == last) continue;
			dfs(v, x, dep + 1);
		}
		id[x] = TOT++;
	}
}

vector <int> label(int n, int k, vector <int> X, vector <int> Y) {
	for (int i = 0; i < n; i++) {
		from[i].clear();
	}
	for (int i = 0; i < n - 1; i++) {
		from[X[i]].push_back(Y[i]);
		from[Y[i]].push_back(X[i]);
	}
	id.resize(n), TOT = 0, dfs(0, 0, 1);
	return id;
}

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

Compilation message

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:12:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for (int i = 0; i < from[x].size(); i++) {
      |                   ~~^~~~~~~~~~~~~~~~
stations.cpp:18:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for (int i = 0; i < from[x].size(); i++) {
      |                   ~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:42:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for (int i = 0; i + 1 < c.size(); i++) {
      |                   ~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 554 ms 1024 KB Output is correct
2 Correct 447 ms 1024 KB Output is correct
3 Correct 895 ms 880 KB Output is correct
4 Correct 721 ms 876 KB Output is correct
5 Correct 602 ms 896 KB Output is correct
6 Correct 525 ms 768 KB Output is correct
7 Correct 530 ms 1040 KB Output is correct
8 Correct 3 ms 876 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 501 ms 804 KB Output is correct
2 Correct 566 ms 824 KB Output is correct
3 Correct 1041 ms 768 KB Output is correct
4 Correct 690 ms 1012 KB Output is correct
5 Correct 615 ms 884 KB Output is correct
6 Correct 461 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 640 ms 1024 KB Output is correct
2 Correct 442 ms 1024 KB Output is correct
3 Correct 926 ms 1012 KB Output is correct
4 Correct 879 ms 768 KB Output is correct
5 Correct 653 ms 872 KB Output is correct
6 Correct 550 ms 1024 KB Output is correct
7 Correct 485 ms 1024 KB Output is correct
8 Correct 1 ms 888 KB Output is correct
9 Correct 4 ms 888 KB Output is correct
10 Correct 2 ms 1036 KB Output is correct
11 Correct 574 ms 876 KB Output is correct
12 Correct 454 ms 1024 KB Output is correct
13 Correct 506 ms 1020 KB Output is correct
14 Correct 483 ms 828 KB Output is correct
15 Correct 57 ms 1160 KB Output is correct
16 Correct 89 ms 768 KB Output is correct
17 Correct 136 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 915 ms 768 KB Output is correct
2 Correct 705 ms 768 KB Output is correct
3 Correct 799 ms 876 KB Output is correct
4 Correct 3 ms 884 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 611 ms 768 KB Output is correct
8 Correct 887 ms 876 KB Output is correct
9 Correct 678 ms 896 KB Output is correct
10 Correct 619 ms 884 KB Output is correct
11 Correct 6 ms 884 KB Output is correct
12 Correct 7 ms 880 KB Output is correct
13 Correct 6 ms 768 KB Output is correct
14 Correct 4 ms 768 KB Output is correct
15 Correct 1 ms 876 KB Output is correct
16 Correct 597 ms 1040 KB Output is correct
17 Correct 642 ms 768 KB Output is correct
18 Correct 534 ms 768 KB Output is correct
19 Correct 734 ms 896 KB Output is correct
20 Correct 531 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 532 ms 1024 KB Output is correct
2 Correct 491 ms 1008 KB Output is correct
3 Correct 866 ms 768 KB Output is correct
4 Correct 696 ms 884 KB Output is correct
5 Correct 608 ms 1024 KB Output is correct
6 Correct 469 ms 1024 KB Output is correct
7 Correct 469 ms 792 KB Output is correct
8 Correct 3 ms 880 KB Output is correct
9 Correct 5 ms 872 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 461 ms 808 KB Output is correct
12 Correct 544 ms 768 KB Output is correct
13 Correct 985 ms 872 KB Output is correct
14 Correct 752 ms 1024 KB Output is correct
15 Correct 684 ms 768 KB Output is correct
16 Correct 510 ms 896 KB Output is correct
17 Correct 676 ms 880 KB Output is correct
18 Correct 527 ms 896 KB Output is correct
19 Correct 557 ms 1124 KB Output is correct
20 Correct 557 ms 824 KB Output is correct
21 Correct 57 ms 880 KB Output is correct
22 Correct 68 ms 840 KB Output is correct
23 Correct 136 ms 768 KB Output is correct
24 Correct 4 ms 880 KB Output is correct
25 Correct 6 ms 768 KB Output is correct
26 Correct 3 ms 876 KB Output is correct
27 Correct 4 ms 768 KB Output is correct
28 Correct 1 ms 876 KB Output is correct
29 Correct 556 ms 768 KB Output is correct
30 Correct 563 ms 876 KB Output is correct
31 Correct 537 ms 1024 KB Output is correct
32 Correct 577 ms 872 KB Output is correct
33 Correct 571 ms 876 KB Output is correct
34 Correct 373 ms 768 KB Output is correct
35 Correct 566 ms 1024 KB Output is correct
36 Correct 456 ms 1024 KB Output is correct
37 Correct 479 ms 776 KB Output is correct
38 Correct 445 ms 1024 KB Output is correct
39 Correct 443 ms 892 KB Output is correct
40 Correct 445 ms 1024 KB Output is correct
41 Correct 467 ms 784 KB Output is correct
42 Correct 62 ms 820 KB Output is correct
43 Correct 108 ms 768 KB Output is correct
44 Correct 125 ms 804 KB Output is correct
45 Correct 154 ms 768 KB Output is correct
46 Correct 306 ms 768 KB Output is correct
47 Correct 317 ms 796 KB Output is correct
48 Correct 57 ms 776 KB Output is correct
49 Correct 62 ms 1024 KB Output is correct