Submission #372845

# Submission time Handle Problem Language Result Execution time Memory
372845 2021-03-02T01:52:19 Z Ozy Stations (IOI20_stations) C++17
100 / 100
1055 ms 1408 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli int
#define debug(a) cout << #a << ' ' << a << endl

lli cont,tam;
vector<lli> hijos[1002],res;

void llena(lli pos, lli padre, lli pp) {

    if (pp == 1) res[pos] = cont++;

    for (auto h : hijos[pos]) {
        if (h == padre) continue;

        if (pp == 1) llena(h,pos,0);
        else llena(h,pos,1);
    }

    if (pp == 0) res[pos] = cont++;

}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {

	res.clear();
	res.resize(n);
	rep(i,0,n-1) hijos[i].clear();

	rep(i,0,n-2) {
        hijos[u[i]].push_back(v[i]);
        hijos[v[i]].push_back(u[i]);
	}
	cont = 0;
	llena(0,-1,1);

	return res;
}

int find_next_station(int s, int t, std::vector<int> c) {
	int ini,fin;

	ini = c[0];
	fin = c[c.size()-1];

	if (ini > s) {

        if (t < s) return fin;
        if (t > fin) return fin;
        for (auto h : c) {
            if (t <= h) return h;
        }
	}
	else {
        if (t > s) return ini;
        if (t < ini) return ini;

        tam = c.size()-1;
        repa(i,tam,0) {
            if (t >= c[i]) return c[i];
        }
	}
    return s;
}
# Verdict Execution time Memory Grader output
1 Correct 624 ms 992 KB Output is correct
2 Correct 495 ms 960 KB Output is correct
3 Correct 1055 ms 1080 KB Output is correct
4 Correct 695 ms 992 KB Output is correct
5 Correct 628 ms 748 KB Output is correct
6 Correct 455 ms 992 KB Output is correct
7 Correct 520 ms 1120 KB Output is correct
8 Correct 3 ms 952 KB Output is correct
9 Correct 5 ms 864 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 514 ms 884 KB Output is correct
2 Correct 517 ms 736 KB Output is correct
3 Correct 913 ms 864 KB Output is correct
4 Correct 764 ms 864 KB Output is correct
5 Correct 758 ms 864 KB Output is correct
6 Correct 506 ms 900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 529 ms 1084 KB Output is correct
2 Correct 459 ms 992 KB Output is correct
3 Correct 915 ms 884 KB Output is correct
4 Correct 810 ms 952 KB Output is correct
5 Correct 621 ms 952 KB Output is correct
6 Correct 453 ms 1092 KB Output is correct
7 Correct 409 ms 1120 KB Output is correct
8 Correct 3 ms 952 KB Output is correct
9 Correct 5 ms 952 KB Output is correct
10 Correct 3 ms 864 KB Output is correct
11 Correct 687 ms 772 KB Output is correct
12 Correct 497 ms 1408 KB Output is correct
13 Correct 435 ms 1064 KB Output is correct
14 Correct 447 ms 1028 KB Output is correct
15 Correct 53 ms 864 KB Output is correct
16 Correct 70 ms 736 KB Output is correct
17 Correct 121 ms 884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 993 ms 736 KB Output is correct
2 Correct 635 ms 952 KB Output is correct
3 Correct 744 ms 992 KB Output is correct
4 Correct 3 ms 960 KB Output is correct
5 Correct 6 ms 904 KB Output is correct
6 Correct 2 ms 864 KB Output is correct
7 Correct 772 ms 736 KB Output is correct
8 Correct 1012 ms 736 KB Output is correct
9 Correct 724 ms 836 KB Output is correct
10 Correct 578 ms 952 KB Output is correct
11 Correct 6 ms 952 KB Output is correct
12 Correct 6 ms 952 KB Output is correct
13 Correct 5 ms 960 KB Output is correct
14 Correct 4 ms 952 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 508 ms 992 KB Output is correct
17 Correct 545 ms 1120 KB Output is correct
18 Correct 528 ms 1080 KB Output is correct
19 Correct 576 ms 960 KB Output is correct
20 Correct 604 ms 952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 596 ms 1088 KB Output is correct
2 Correct 554 ms 1092 KB Output is correct
3 Correct 939 ms 1108 KB Output is correct
4 Correct 728 ms 864 KB Output is correct
5 Correct 631 ms 1080 KB Output is correct
6 Correct 455 ms 1116 KB Output is correct
7 Correct 481 ms 864 KB Output is correct
8 Correct 3 ms 960 KB Output is correct
9 Correct 3 ms 736 KB Output is correct
10 Correct 1 ms 736 KB Output is correct
11 Correct 537 ms 1172 KB Output is correct
12 Correct 577 ms 864 KB Output is correct
13 Correct 932 ms 952 KB Output is correct
14 Correct 822 ms 736 KB Output is correct
15 Correct 688 ms 952 KB Output is correct
16 Correct 465 ms 900 KB Output is correct
17 Correct 601 ms 1108 KB Output is correct
18 Correct 506 ms 1120 KB Output is correct
19 Correct 492 ms 864 KB Output is correct
20 Correct 464 ms 908 KB Output is correct
21 Correct 58 ms 952 KB Output is correct
22 Correct 80 ms 736 KB Output is correct
23 Correct 129 ms 736 KB Output is correct
24 Correct 7 ms 864 KB Output is correct
25 Correct 5 ms 736 KB Output is correct
26 Correct 6 ms 952 KB Output is correct
27 Correct 4 ms 952 KB Output is correct
28 Correct 2 ms 952 KB Output is correct
29 Correct 533 ms 736 KB Output is correct
30 Correct 555 ms 1108 KB Output is correct
31 Correct 697 ms 864 KB Output is correct
32 Correct 615 ms 864 KB Output is correct
33 Correct 577 ms 896 KB Output is correct
34 Correct 294 ms 1104 KB Output is correct
35 Correct 515 ms 1080 KB Output is correct
36 Correct 573 ms 1092 KB Output is correct
37 Correct 535 ms 864 KB Output is correct
38 Correct 499 ms 1252 KB Output is correct
39 Correct 536 ms 1120 KB Output is correct
40 Correct 450 ms 1236 KB Output is correct
41 Correct 451 ms 992 KB Output is correct
42 Correct 62 ms 908 KB Output is correct
43 Correct 97 ms 884 KB Output is correct
44 Correct 114 ms 992 KB Output is correct
45 Correct 168 ms 864 KB Output is correct
46 Correct 359 ms 904 KB Output is correct
47 Correct 355 ms 864 KB Output is correct
48 Correct 70 ms 1092 KB Output is correct
49 Correct 62 ms 1216 KB Output is correct