Submission #578578

# Submission time Handle Problem Language Result Execution time Memory
578578 2022-06-17T10:16:40 Z Vanilla Stations (IOI20_stations) C++17
100 / 100
996 ms 912 KB
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
const int maxn = 1002;
vector <int> ad [maxn];
int ct = 0;

int get_nd (int x) {
	return x / 2;
}

void dfs (int u, int p, int dp, vector <int> &lb) {
	if (dp % 2 == 0) lb[u] = ct++;
	int mx = 0;
	for (int v: ad[u]) {
		if (v == p) continue;
		dfs(v, u, dp + 1, lb);
	}
	if (dp % 2 == 1) lb[u]=ct++;
	
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(n);
	vector <int> norm (n);
	ct = 0;
	for (int i = 0; i < n; i++){
		ad[i].clear();
	}
	for (int i = 0; i < n - 1; i++){
		ad[u[i]].push_back(v[i]);
		ad[v[i]].push_back(u[i]);
	}
	dfs(0, -1, 0, labels);
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	if (c[0] > s) {
		if (t < s) return c.back();
		auto it = lower_bound(c.begin(), c.end(), t);
		if (it == c.end()) it--;
		return *it;
	}
	if (t > s) return c[0];
	auto it = upper_bound(c.begin(), c.end(), t);
	if (it != c.begin()) it--;
	return *it;
}

Compilation message

stations.cpp: In function 'void dfs(int, int, int, std::vector<int>&)':
stations.cpp:14:6: warning: unused variable 'mx' [-Wunused-variable]
   14 |  int mx = 0;
      |      ^~
# Verdict Execution time Memory Grader output
1 Correct 582 ms 544 KB Output is correct
2 Correct 532 ms 540 KB Output is correct
3 Correct 890 ms 416 KB Output is correct
4 Correct 712 ms 528 KB Output is correct
5 Correct 611 ms 416 KB Output is correct
6 Correct 418 ms 644 KB Output is correct
7 Correct 461 ms 548 KB Output is correct
8 Correct 1 ms 488 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 510 ms 520 KB Output is correct
2 Correct 610 ms 536 KB Output is correct
3 Correct 887 ms 420 KB Output is correct
4 Correct 682 ms 520 KB Output is correct
5 Correct 519 ms 532 KB Output is correct
6 Correct 481 ms 520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 510 ms 664 KB Output is correct
2 Correct 494 ms 544 KB Output is correct
3 Correct 930 ms 416 KB Output is correct
4 Correct 545 ms 528 KB Output is correct
5 Correct 635 ms 420 KB Output is correct
6 Correct 489 ms 656 KB Output is correct
7 Correct 398 ms 548 KB Output is correct
8 Correct 3 ms 500 KB Output is correct
9 Correct 4 ms 500 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 518 ms 416 KB Output is correct
12 Correct 507 ms 776 KB Output is correct
13 Correct 418 ms 544 KB Output is correct
14 Correct 472 ms 544 KB Output is correct
15 Correct 54 ms 628 KB Output is correct
16 Correct 62 ms 740 KB Output is correct
17 Correct 104 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 880 ms 504 KB Output is correct
2 Correct 601 ms 416 KB Output is correct
3 Correct 627 ms 416 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 5 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 511 ms 532 KB Output is correct
8 Correct 988 ms 524 KB Output is correct
9 Correct 764 ms 528 KB Output is correct
10 Correct 529 ms 552 KB Output is correct
11 Correct 5 ms 496 KB Output is correct
12 Correct 6 ms 496 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 4 ms 492 KB Output is correct
15 Correct 2 ms 488 KB Output is correct
16 Correct 497 ms 532 KB Output is correct
17 Correct 558 ms 588 KB Output is correct
18 Correct 466 ms 524 KB Output is correct
19 Correct 488 ms 524 KB Output is correct
20 Correct 529 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 555 ms 636 KB Output is correct
2 Correct 460 ms 544 KB Output is correct
3 Correct 996 ms 512 KB Output is correct
4 Correct 809 ms 464 KB Output is correct
5 Correct 644 ms 528 KB Output is correct
6 Correct 462 ms 636 KB Output is correct
7 Correct 456 ms 548 KB Output is correct
8 Correct 2 ms 496 KB Output is correct
9 Correct 3 ms 500 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 487 ms 528 KB Output is correct
12 Correct 507 ms 532 KB Output is correct
13 Correct 949 ms 420 KB Output is correct
14 Correct 643 ms 420 KB Output is correct
15 Correct 602 ms 536 KB Output is correct
16 Correct 436 ms 548 KB Output is correct
17 Correct 621 ms 416 KB Output is correct
18 Correct 421 ms 768 KB Output is correct
19 Correct 504 ms 624 KB Output is correct
20 Correct 451 ms 548 KB Output is correct
21 Correct 54 ms 492 KB Output is correct
22 Correct 49 ms 544 KB Output is correct
23 Correct 110 ms 656 KB Output is correct
24 Correct 6 ms 500 KB Output is correct
25 Correct 5 ms 496 KB Output is correct
26 Correct 4 ms 488 KB Output is correct
27 Correct 4 ms 500 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 492 ms 420 KB Output is correct
30 Correct 581 ms 420 KB Output is correct
31 Correct 513 ms 420 KB Output is correct
32 Correct 561 ms 532 KB Output is correct
33 Correct 510 ms 528 KB Output is correct
34 Correct 352 ms 544 KB Output is correct
35 Correct 406 ms 676 KB Output is correct
36 Correct 453 ms 648 KB Output is correct
37 Correct 469 ms 652 KB Output is correct
38 Correct 392 ms 744 KB Output is correct
39 Correct 465 ms 668 KB Output is correct
40 Correct 414 ms 912 KB Output is correct
41 Correct 455 ms 640 KB Output is correct
42 Correct 57 ms 572 KB Output is correct
43 Correct 99 ms 572 KB Output is correct
44 Correct 106 ms 548 KB Output is correct
45 Correct 135 ms 544 KB Output is correct
46 Correct 268 ms 580 KB Output is correct
47 Correct 313 ms 548 KB Output is correct
48 Correct 67 ms 688 KB Output is correct
49 Correct 62 ms 700 KB Output is correct