Submission #410517

# Submission time Handle Problem Language Result Execution time Memory
410517 2021-05-22T21:01:21 Z 534351 Stations (IOI20_stations) C++17
52.3205 / 100
1170 ms 720 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()

const int MAXN = 1013;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N, K, T;
vi edge[MAXN];
int st[MAXN], ft[MAXN];
vi ans;
//inside each vtx, we store start time and finish time.

void dfs(int u, int p)
{
	st[u] = T;
	ft[u] = T;
	T++;
	for (int v : edge[u])
	{
		if (v == p) continue;
		dfs(v, u);
		ft[u] = ft[v];
	}
}

vi label(int n, int k, vi U, vi V)
{
	N = n; K = k; T = 0;
	FOR(i, 0, N)
	{
		edge[i].clear();
	}
	ans.clear();
	FOR(i, 0, N - 1)
	{
		int u = U[i], v = V[i];
		edge[u].PB(v);
		edge[v].PB(u);
	}
	dfs(0, N);
	ans.resize(N);
	FOR(i, 0, N)
	{
		ans[i] = st[i] * 1000 + ft[i];
	}
	return ans;
}

int find_next_station(int s, int t, vi ch)
{
	//you're at s and you want to go to t.
	int stu = s / 1000, ftu = s % 1000;
	int stv = t / 1000, ftv = t % 1000;
	if (stu <= stv && stv <= ftu)
	{
		for (int x : ch)
		{
			int stx = x / 1000, ftx = x % 1000;
			if (stx < stu) continue;
			if (stx <= stv && stv <= ftx)
			{
				return x;
			}
		}
	}
	for (int x : ch)
	{
		int stx = x / 1000, ftx = x % 1000;
		if (stx < stu) return x;
	}
	assert(false);
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, vi)':
stations.cpp:101:23: warning: unused variable 'ftx' [-Wunused-variable]
  101 |   int stx = x / 1000, ftx = x % 1000;
      |                       ^~~
stations.cpp:86:22: warning: unused variable 'ftv' [-Wunused-variable]
   86 |  int stv = t / 1000, ftv = t % 1000;
      |                      ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 456 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 328 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 634 ms 660 KB Output is correct
2 Correct 537 ms 528 KB Output is correct
3 Correct 1132 ms 400 KB Output is correct
4 Correct 740 ms 516 KB Output is correct
5 Correct 633 ms 404 KB Output is correct
6 Correct 510 ms 636 KB Output is correct
7 Correct 521 ms 520 KB Output is correct
8 Correct 3 ms 476 KB Output is correct
9 Correct 6 ms 440 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 546 ms 516 KB Output is correct
12 Correct 466 ms 644 KB Output is correct
13 Correct 607 ms 636 KB Output is correct
14 Correct 453 ms 512 KB Output is correct
15 Correct 71 ms 532 KB Output is correct
16 Correct 87 ms 548 KB Output is correct
17 Correct 101 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 961 ms 400 KB Output is correct
2 Correct 668 ms 516 KB Output is correct
3 Correct 853 ms 516 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 6 ms 480 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 785 ms 400 KB Output is correct
8 Correct 1170 ms 400 KB Output is correct
9 Correct 779 ms 580 KB Output is correct
10 Correct 699 ms 400 KB Output is correct
11 Correct 7 ms 596 KB Output is correct
12 Correct 6 ms 612 KB Output is correct
13 Correct 4 ms 468 KB Output is correct
14 Correct 5 ms 476 KB Output is correct
15 Correct 2 ms 480 KB Output is correct
16 Correct 627 ms 528 KB Output is correct
17 Correct 624 ms 400 KB Output is correct
18 Correct 667 ms 528 KB Output is correct
19 Correct 554 ms 512 KB Output is correct
20 Correct 665 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 611 ms 668 KB Partially correct
2 Partially correct 554 ms 656 KB Partially correct
3 Partially correct 1019 ms 400 KB Partially correct
4 Partially correct 857 ms 524 KB Partially correct
5 Partially correct 669 ms 400 KB Partially correct
6 Partially correct 564 ms 656 KB Partially correct
7 Partially correct 539 ms 516 KB Partially correct
8 Partially correct 3 ms 468 KB Partially correct
9 Partially correct 6 ms 476 KB Partially correct
10 Partially correct 2 ms 468 KB Partially correct
11 Partially correct 487 ms 588 KB Partially correct
12 Partially correct 685 ms 680 KB Partially correct
13 Partially correct 1017 ms 528 KB Partially correct
14 Partially correct 678 ms 532 KB Partially correct
15 Partially correct 769 ms 400 KB Partially correct
16 Partially correct 500 ms 528 KB Partially correct
17 Partially correct 676 ms 496 KB Partially correct
18 Partially correct 549 ms 720 KB Partially correct
19 Partially correct 632 ms 624 KB Partially correct
20 Partially correct 484 ms 516 KB Partially correct
21 Partially correct 68 ms 528 KB Partially correct
22 Partially correct 71 ms 544 KB Partially correct
23 Partially correct 147 ms 528 KB Partially correct
24 Partially correct 5 ms 604 KB Partially correct
25 Partially correct 6 ms 476 KB Partially correct
26 Partially correct 4 ms 476 KB Partially correct
27 Partially correct 5 ms 468 KB Partially correct
28 Partially correct 2 ms 480 KB Partially correct
29 Partially correct 466 ms 520 KB Partially correct
30 Partially correct 541 ms 400 KB Partially correct
31 Partially correct 678 ms 528 KB Partially correct
32 Partially correct 670 ms 584 KB Partially correct
33 Partially correct 677 ms 720 KB Partially correct
34 Partially correct 365 ms 528 KB Partially correct
35 Partially correct 569 ms 636 KB Partially correct
36 Partially correct 536 ms 648 KB Partially correct
37 Partially correct 574 ms 648 KB Partially correct
38 Partially correct 565 ms 512 KB Partially correct
39 Partially correct 522 ms 624 KB Partially correct
40 Partially correct 568 ms 640 KB Partially correct
41 Partially correct 621 ms 644 KB Partially correct
42 Partially correct 65 ms 528 KB Partially correct
43 Partially correct 104 ms 656 KB Partially correct
44 Partially correct 134 ms 528 KB Partially correct
45 Partially correct 228 ms 600 KB Partially correct
46 Partially correct 398 ms 508 KB Partially correct
47 Partially correct 309 ms 528 KB Partially correct
48 Partially correct 82 ms 664 KB Partially correct
49 Partially correct 79 ms 688 KB Partially correct