Submission #398437

# Submission time Handle Problem Language Result Execution time Memory
398437 2021-05-04T09:29:32 Z kevinxiehk Stations (IOI20_stations) C++17
100 / 100
1214 ms 784 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
#define pb emplace_back
using namespace std;
int lb[1005];
vector<int> conn[1005];
bool vi[1005];
int id = 0;
void dfs(int depth, int now) {
	vi[now] = true;
	if(depth % 2 == 0) {
		lb[now] = id;
		id++;
		for(auto x: conn[now]) if(!vi[x]) dfs(depth + 1, x);
	}
	else {
		for(auto x: conn[now]) if(!vi[x]) dfs(depth + 1, x);
		lb[now] = id;
		id++;
	}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	id = 0;
	vector<int> labels(n);
	for (int i = 0; i < n; i++) {
		conn[i].clear();
		vi[i] = false;
	}
	for(int i = 0; i < n - 1; i++) {
		conn[u[i]].pb(v[i]);
		conn[v[i]].pb(u[i]);
	}
	dfs(0, 0);
	for(int i = 0; i < n; i++) {
		labels[i] = lb[i];
	}
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	if(c.size() == 1) return c[0];
	if(s < c[0]) {
		if(t < s || t >= c[c.size() - 1]) {
			return c[c.size() - 1];
		}
		int a = 0;
		while(c[a] < t) a++;
		return c[a];
	}
	else{
		if(t > s || t <= c[0]) {
			return c[0];
		}
		int a = c.size() - 1;
		while(c[a] > t) a--;
		return c[a];
	}
}
# Verdict Execution time Memory Grader output
1 Correct 658 ms 520 KB Output is correct
2 Correct 468 ms 512 KB Output is correct
3 Correct 1160 ms 552 KB Output is correct
4 Correct 933 ms 400 KB Output is correct
5 Correct 661 ms 648 KB Output is correct
6 Correct 559 ms 516 KB Output is correct
7 Correct 560 ms 624 KB Output is correct
8 Correct 3 ms 480 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 568 ms 524 KB Output is correct
2 Correct 583 ms 680 KB Output is correct
3 Correct 919 ms 500 KB Output is correct
4 Correct 648 ms 656 KB Output is correct
5 Correct 646 ms 520 KB Output is correct
6 Correct 612 ms 516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 539 ms 728 KB Output is correct
2 Correct 552 ms 736 KB Output is correct
3 Correct 1138 ms 520 KB Output is correct
4 Correct 763 ms 436 KB Output is correct
5 Correct 665 ms 400 KB Output is correct
6 Correct 485 ms 520 KB Output is correct
7 Correct 459 ms 508 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 4 ms 480 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
11 Correct 729 ms 516 KB Output is correct
12 Correct 615 ms 744 KB Output is correct
13 Correct 546 ms 640 KB Output is correct
14 Correct 622 ms 528 KB Output is correct
15 Correct 64 ms 528 KB Output is correct
16 Correct 73 ms 656 KB Output is correct
17 Correct 140 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1013 ms 524 KB Output is correct
2 Correct 780 ms 528 KB Output is correct
3 Correct 739 ms 528 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 4 ms 472 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 650 ms 520 KB Output is correct
8 Correct 1136 ms 400 KB Output is correct
9 Correct 852 ms 528 KB Output is correct
10 Correct 724 ms 528 KB Output is correct
11 Correct 7 ms 472 KB Output is correct
12 Correct 5 ms 600 KB Output is correct
13 Correct 6 ms 472 KB Output is correct
14 Correct 5 ms 600 KB Output is correct
15 Correct 2 ms 472 KB Output is correct
16 Correct 623 ms 640 KB Output is correct
17 Correct 561 ms 520 KB Output is correct
18 Correct 582 ms 400 KB Output is correct
19 Correct 556 ms 512 KB Output is correct
20 Correct 645 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 644 ms 516 KB Output is correct
2 Correct 673 ms 516 KB Output is correct
3 Correct 1214 ms 512 KB Output is correct
4 Correct 797 ms 536 KB Output is correct
5 Correct 725 ms 516 KB Output is correct
6 Correct 457 ms 528 KB Output is correct
7 Correct 577 ms 528 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 4 ms 480 KB Output is correct
10 Correct 2 ms 480 KB Output is correct
11 Correct 505 ms 504 KB Output is correct
12 Correct 626 ms 520 KB Output is correct
13 Correct 1126 ms 528 KB Output is correct
14 Correct 804 ms 400 KB Output is correct
15 Correct 654 ms 528 KB Output is correct
16 Correct 551 ms 492 KB Output is correct
17 Correct 704 ms 640 KB Output is correct
18 Correct 505 ms 624 KB Output is correct
19 Correct 496 ms 508 KB Output is correct
20 Correct 491 ms 528 KB Output is correct
21 Correct 73 ms 528 KB Output is correct
22 Correct 82 ms 656 KB Output is correct
23 Correct 107 ms 660 KB Output is correct
24 Correct 7 ms 472 KB Output is correct
25 Correct 5 ms 472 KB Output is correct
26 Correct 6 ms 472 KB Output is correct
27 Correct 4 ms 472 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 573 ms 400 KB Output is correct
30 Correct 520 ms 640 KB Output is correct
31 Correct 497 ms 400 KB Output is correct
32 Correct 556 ms 532 KB Output is correct
33 Correct 632 ms 648 KB Output is correct
34 Correct 352 ms 528 KB Output is correct
35 Correct 461 ms 628 KB Output is correct
36 Correct 461 ms 520 KB Output is correct
37 Correct 543 ms 668 KB Output is correct
38 Correct 489 ms 508 KB Output is correct
39 Correct 467 ms 656 KB Output is correct
40 Correct 449 ms 632 KB Output is correct
41 Correct 540 ms 776 KB Output is correct
42 Correct 60 ms 708 KB Output is correct
43 Correct 97 ms 784 KB Output is correct
44 Correct 175 ms 600 KB Output is correct
45 Correct 167 ms 516 KB Output is correct
46 Correct 389 ms 512 KB Output is correct
47 Correct 388 ms 532 KB Output is correct
48 Correct 75 ms 672 KB Output is correct
49 Correct 77 ms 656 KB Output is correct