Submission #769687

# Submission time Handle Problem Language Result Execution time Memory
769687 2023-06-30T03:08:26 Z marvinthang Stations (IOI20_stations) C++17
100 / 100
729 ms 752 KB
/*************************************
*    author: marvinthang             *
*    created: 30.06.2023 09:44:04    *
*************************************/

#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

#define                  fi  first
#define                  se  second
#define                left  ___left
#define               right  ___right
#define                TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define             MASK(i)  (1LL << (i))
#define           BIT(x, i)  ((x) >> (i) & 1)
#define  __builtin_popcount  __builtin_popcountll
#define              ALL(v)  (v).begin(), (v).end()
#define           REP(i, n)  for (int i = 0, _n = (n); i < _n; ++i)
#define          REPD(i, n)  for (int i = (n); i--; )
#define        FOR(i, a, b)  for (int i = (a), _b = (b); i < _b; ++i) 
#define       FORD(i, b, a)  for (int i = (b), _a = (a); --i >= _a; ) 
#define       FORE(i, a, b)  for (int i = (a), _b = (b); i <= _b; ++i) 
#define      FORDE(i, b, a)  for (int i = (b), _a = (a); i >= _a; --i) 
#define        scan_op(...)  istream & operator >> (istream &in, __VA_ARGS__ &u)
#define       print_op(...)  ostream & operator << (ostream &out, const __VA_ARGS__ &u)
#ifdef LOCAL
    #include "debug.h"
#else
    #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
    #define DB(...) 23
    #define db(...) 23
    #define debug(...) 23
#endif

template <class U, class V> scan_op(pair <U, V>)  { return in >> u.first >> u.second; }
template <class T> scan_op(vector <T>)  { for (size_t i = 0; i < u.size(); ++i) in >> u[i]; return in; }
template <class U, class V> print_op(pair <U, V>)  { return out << '(' << u.first << ", " << u.second << ')'; }
template <size_t i, class T> ostream & print_tuple_utils(ostream &out, const T &tup) { if constexpr(i == tuple_size<T>::value) return out << ")";  else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup); }
template <class ...U> print_op(tuple<U...>) { return print_tuple_utils<0, tuple<U...>>(out, u); }
template <class Con, class = decltype(begin(declval<Con>()))> typename enable_if <!is_same<Con, string>::value, ostream&>::type operator << (ostream &out, const Con &con) { out << '{'; for (__typeof(con.begin()) it = con.begin(); it != con.end(); ++it) out << (it == con.begin() ? "" : ", ") << *it; return out << '}'; }

// end of template

vector <int> label(int n, int k, vector <int> u, vector <int> v) {
	vector <vector <int>> adj(n);
	REP(i, n - 1) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	int timeDfs = 0;
	vector <int> lb(n);
	function<void(int, int, int)> dfs = [&] (int u, int par, int p) {
		if (p) lb[u] = timeDfs++;
		for (int v: adj[u]) if (v != par) dfs(v, u, p ^ 1);
		if (!p) lb[u] = timeDfs++;
	};
	dfs(0, 0, 1);
	return lb;
}

int find_next_station(int s, int t, vector <int> c) {
	if (s < c[0]) {
		if (t < s || t >= c.back()) return c.back();
		for (int x: c) if (t <= x) return x;
	}
	if (t <= c[0] || t > s) return c[0];
	reverse(ALL(c));
	for (int x: c) if (x <= t) return x;
	return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 465 ms 632 KB Output is correct
2 Correct 341 ms 652 KB Output is correct
3 Correct 625 ms 420 KB Output is correct
4 Correct 419 ms 416 KB Output is correct
5 Correct 363 ms 508 KB Output is correct
6 Correct 435 ms 628 KB Output is correct
7 Correct 287 ms 540 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 418 ms 588 KB Output is correct
2 Correct 409 ms 508 KB Output is correct
3 Correct 643 ms 508 KB Output is correct
4 Correct 542 ms 500 KB Output is correct
5 Correct 452 ms 504 KB Output is correct
6 Correct 432 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 441 ms 676 KB Output is correct
2 Correct 313 ms 672 KB Output is correct
3 Correct 619 ms 420 KB Output is correct
4 Correct 544 ms 488 KB Output is correct
5 Correct 454 ms 504 KB Output is correct
6 Correct 369 ms 636 KB Output is correct
7 Correct 384 ms 636 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 4 ms 488 KB Output is correct
10 Correct 2 ms 488 KB Output is correct
11 Correct 408 ms 416 KB Output is correct
12 Correct 404 ms 712 KB Output is correct
13 Correct 436 ms 672 KB Output is correct
14 Correct 336 ms 544 KB Output is correct
15 Correct 47 ms 472 KB Output is correct
16 Correct 55 ms 600 KB Output is correct
17 Correct 86 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 622 ms 508 KB Output is correct
2 Correct 406 ms 416 KB Output is correct
3 Correct 522 ms 508 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 462 ms 500 KB Output is correct
8 Correct 729 ms 508 KB Output is correct
9 Correct 564 ms 416 KB Output is correct
10 Correct 547 ms 504 KB Output is correct
11 Correct 4 ms 500 KB Output is correct
12 Correct 3 ms 500 KB Output is correct
13 Correct 3 ms 444 KB Output is correct
14 Correct 2 ms 500 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 422 ms 416 KB Output is correct
17 Correct 490 ms 416 KB Output is correct
18 Correct 459 ms 504 KB Output is correct
19 Correct 310 ms 420 KB Output is correct
20 Correct 405 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 430 ms 676 KB Output is correct
2 Correct 373 ms 616 KB Output is correct
3 Correct 633 ms 416 KB Output is correct
4 Correct 532 ms 420 KB Output is correct
5 Correct 479 ms 416 KB Output is correct
6 Correct 373 ms 672 KB Output is correct
7 Correct 363 ms 632 KB Output is correct
8 Correct 1 ms 500 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 404 ms 508 KB Output is correct
12 Correct 469 ms 532 KB Output is correct
13 Correct 646 ms 504 KB Output is correct
14 Correct 518 ms 504 KB Output is correct
15 Correct 513 ms 508 KB Output is correct
16 Correct 287 ms 548 KB Output is correct
17 Correct 560 ms 416 KB Output is correct
18 Correct 377 ms 708 KB Output is correct
19 Correct 336 ms 708 KB Output is correct
20 Correct 410 ms 556 KB Output is correct
21 Correct 36 ms 416 KB Output is correct
22 Correct 48 ms 620 KB Output is correct
23 Correct 72 ms 532 KB Output is correct
24 Correct 5 ms 492 KB Output is correct
25 Correct 3 ms 488 KB Output is correct
26 Correct 4 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 428 ms 500 KB Output is correct
30 Correct 403 ms 504 KB Output is correct
31 Correct 493 ms 416 KB Output is correct
32 Correct 387 ms 416 KB Output is correct
33 Correct 368 ms 416 KB Output is correct
34 Correct 246 ms 632 KB Output is correct
35 Correct 363 ms 676 KB Output is correct
36 Correct 412 ms 752 KB Output is correct
37 Correct 404 ms 592 KB Output is correct
38 Correct 286 ms 660 KB Output is correct
39 Correct 332 ms 736 KB Output is correct
40 Correct 342 ms 596 KB Output is correct
41 Correct 271 ms 632 KB Output is correct
42 Correct 55 ms 512 KB Output is correct
43 Correct 90 ms 544 KB Output is correct
44 Correct 93 ms 576 KB Output is correct
45 Correct 147 ms 584 KB Output is correct
46 Correct 272 ms 504 KB Output is correct
47 Correct 210 ms 544 KB Output is correct
48 Correct 53 ms 536 KB Output is correct
49 Correct 48 ms 676 KB Output is correct