Submission #800126

# Submission time Handle Problem Language Result Execution time Memory
800126 2023-08-01T10:34:07 Z Magikarp4000 Stations (IOI20_stations) C++17
100 / 100
843 ms 860 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define OPTM ios_base::sync_with_stdio(0); cin.tie(0);
#define INF int(1e9+7)
#define ln '\n' 
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define FOR(i,s,n) for (int i = s; i < n; i++)
#define FORR(i,n,s) for (int i = n; i > s; i--)
#define FORX(u, arr) for (auto u : arr)
#define PB push_back
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define UM unordered_map
#define US unordered_set
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
const ll LLINF = 1e18+1;

const int MAXN = 2e3+5;
int timer;
vector<int> v[MAXN], w;

void dfs(int s, int pa, int d) {
    if (d == 0) w[s] = timer/2;
    timer++;
    FORX(u,v[s]) if (u != pa) dfs(u,s,d^1);
    if (d == 1) w[s] = timer/2;
    timer++;
}

vector<int> label(int n, int k, vector<int> U, vector<int> V) {
    FOR(i,0,n) v[i].clear();
    w.clear();
    timer = 0;
    FOR(i,0,n-1) v[U[i]].PB(V[i]), v[V[i]].PB(U[i]);
    w.resize(n,-1);
    dfs(0,-1,0);
    return w;
}

int find_next_station(int s, int t, vector<int> c) {
    FORX(u,c) if (t == u) return u;
    sort(ALL(c));
    int cn = c.size();
	if (s > c[0]) {
        FOR(i,1,cn-1) if (c[i] < t && c[i+1] > t) return c[i];
        if (c.back() < t && s > t) return c.back();
        return c[0];
    }
    else {
        if (s < t && c[0] > t) return c[0];
        FOR(i,1,cn) if (c[i-1] < t && c[i] > t) return c[i];
        return c.back();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 385 ms 812 KB Output is correct
2 Correct 405 ms 800 KB Output is correct
3 Correct 655 ms 672 KB Output is correct
4 Correct 505 ms 672 KB Output is correct
5 Correct 539 ms 680 KB Output is correct
6 Correct 300 ms 808 KB Output is correct
7 Correct 398 ms 676 KB Output is correct
8 Correct 1 ms 748 KB Output is correct
9 Correct 3 ms 756 KB Output is correct
10 Correct 0 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 301 ms 680 KB Output is correct
2 Correct 362 ms 676 KB Output is correct
3 Correct 686 ms 676 KB Output is correct
4 Correct 573 ms 676 KB Output is correct
5 Correct 400 ms 672 KB Output is correct
6 Correct 302 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 369 ms 800 KB Output is correct
2 Correct 374 ms 804 KB Output is correct
3 Correct 756 ms 672 KB Output is correct
4 Correct 555 ms 680 KB Output is correct
5 Correct 476 ms 672 KB Output is correct
6 Correct 338 ms 732 KB Output is correct
7 Correct 365 ms 740 KB Output is correct
8 Correct 1 ms 748 KB Output is correct
9 Correct 2 ms 752 KB Output is correct
10 Correct 0 ms 752 KB Output is correct
11 Correct 438 ms 680 KB Output is correct
12 Correct 397 ms 808 KB Output is correct
13 Correct 415 ms 804 KB Output is correct
14 Correct 366 ms 684 KB Output is correct
15 Correct 46 ms 700 KB Output is correct
16 Correct 58 ms 716 KB Output is correct
17 Correct 93 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 619 ms 684 KB Output is correct
2 Correct 471 ms 676 KB Output is correct
3 Correct 492 ms 676 KB Output is correct
4 Correct 2 ms 756 KB Output is correct
5 Correct 4 ms 756 KB Output is correct
6 Correct 0 ms 748 KB Output is correct
7 Correct 426 ms 684 KB Output is correct
8 Correct 712 ms 676 KB Output is correct
9 Correct 533 ms 676 KB Output is correct
10 Correct 461 ms 684 KB Output is correct
11 Correct 5 ms 744 KB Output is correct
12 Correct 5 ms 756 KB Output is correct
13 Correct 4 ms 756 KB Output is correct
14 Correct 3 ms 756 KB Output is correct
15 Correct 2 ms 752 KB Output is correct
16 Correct 475 ms 672 KB Output is correct
17 Correct 402 ms 676 KB Output is correct
18 Correct 420 ms 672 KB Output is correct
19 Correct 407 ms 672 KB Output is correct
20 Correct 303 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 493 ms 804 KB Output is correct
2 Correct 381 ms 788 KB Output is correct
3 Correct 843 ms 680 KB Output is correct
4 Correct 516 ms 680 KB Output is correct
5 Correct 456 ms 680 KB Output is correct
6 Correct 332 ms 792 KB Output is correct
7 Correct 306 ms 676 KB Output is correct
8 Correct 1 ms 752 KB Output is correct
9 Correct 4 ms 748 KB Output is correct
10 Correct 0 ms 748 KB Output is correct
11 Correct 321 ms 676 KB Output is correct
12 Correct 456 ms 676 KB Output is correct
13 Correct 774 ms 684 KB Output is correct
14 Correct 479 ms 680 KB Output is correct
15 Correct 497 ms 684 KB Output is correct
16 Correct 319 ms 676 KB Output is correct
17 Correct 419 ms 684 KB Output is correct
18 Correct 372 ms 808 KB Output is correct
19 Correct 274 ms 812 KB Output is correct
20 Correct 436 ms 676 KB Output is correct
21 Correct 47 ms 748 KB Output is correct
22 Correct 65 ms 696 KB Output is correct
23 Correct 100 ms 700 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 5 ms 760 KB Output is correct
26 Correct 4 ms 700 KB Output is correct
27 Correct 3 ms 700 KB Output is correct
28 Correct 1 ms 748 KB Output is correct
29 Correct 497 ms 672 KB Output is correct
30 Correct 358 ms 676 KB Output is correct
31 Correct 321 ms 680 KB Output is correct
32 Correct 385 ms 684 KB Output is correct
33 Correct 444 ms 676 KB Output is correct
34 Correct 284 ms 808 KB Output is correct
35 Correct 398 ms 804 KB Output is correct
36 Correct 388 ms 804 KB Output is correct
37 Correct 435 ms 764 KB Output is correct
38 Correct 442 ms 804 KB Output is correct
39 Correct 440 ms 860 KB Output is correct
40 Correct 306 ms 684 KB Output is correct
41 Correct 449 ms 684 KB Output is correct
42 Correct 53 ms 728 KB Output is correct
43 Correct 78 ms 704 KB Output is correct
44 Correct 118 ms 792 KB Output is correct
45 Correct 157 ms 672 KB Output is correct
46 Correct 219 ms 684 KB Output is correct
47 Correct 284 ms 676 KB Output is correct
48 Correct 48 ms 812 KB Output is correct
49 Correct 48 ms 728 KB Output is correct