Submission #1032041

# Submission time Handle Problem Language Result Execution time Memory
1032041 2024-07-23T10:28:08 Z hotboy2703 Stations (IOI20_stations) C++17
100 / 100
603 ms 1200 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL<<(i))
const ll MAXN = 1010;
vector <ll> g[MAXN];
vector <ll> labels;
ll timeDFS;
void dfs(ll u,ll p,bool dep){
	if (dep==0)labels[u]=timeDFS++;
	for (auto v:g[u]){
		if (v==p)continue;
		dfs(v,u,1-dep);
	}
	if (dep==1)labels[u]=timeDFS++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	timeDFS = 0;
	for (ll i = 0;i < n;i++)g[i].clear();
	for (ll i = 0;i < sz(u);i ++){
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	labels.resize(n);
	dfs(0,0,0);
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	bool dep = 0;
	for (auto x:c)if (x < s)dep = 1;
	if (dep){
		c.push_back(s);
		for (ll j = 1;j + 1 < sz(c);j ++){
			if (c[j] <= t && t < c[j+1])return c[j];
		}
		return c[0];
	}
	else{
		c.insert(c.begin(),s);
		for (ll i = 1;i + 1 < sz(c);i ++){
			if (c[i-1] <= t && t <= c[i])return c[i];
		}
		return c.back();
	}
	return c[0];
}
# Verdict Execution time Memory Grader output
1 Correct 356 ms 684 KB Output is correct
2 Correct 323 ms 940 KB Output is correct
3 Correct 563 ms 684 KB Output is correct
4 Correct 425 ms 684 KB Output is correct
5 Correct 332 ms 684 KB Output is correct
6 Correct 288 ms 684 KB Output is correct
7 Correct 254 ms 684 KB Output is correct
8 Correct 0 ms 776 KB Output is correct
9 Correct 3 ms 764 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 255 ms 868 KB Output is correct
2 Correct 331 ms 684 KB Output is correct
3 Correct 511 ms 684 KB Output is correct
4 Correct 437 ms 684 KB Output is correct
5 Correct 385 ms 940 KB Output is correct
6 Correct 290 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 315 ms 940 KB Output is correct
2 Correct 241 ms 684 KB Output is correct
3 Correct 514 ms 684 KB Output is correct
4 Correct 467 ms 684 KB Output is correct
5 Correct 356 ms 684 KB Output is correct
6 Correct 306 ms 684 KB Output is correct
7 Correct 310 ms 684 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 395 ms 684 KB Output is correct
12 Correct 283 ms 1048 KB Output is correct
13 Correct 334 ms 792 KB Output is correct
14 Correct 274 ms 684 KB Output is correct
15 Correct 36 ms 768 KB Output is correct
16 Correct 35 ms 764 KB Output is correct
17 Correct 71 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 600 ms 684 KB Output is correct
2 Correct 420 ms 684 KB Output is correct
3 Correct 407 ms 684 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 776 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 414 ms 812 KB Output is correct
8 Correct 572 ms 684 KB Output is correct
9 Correct 430 ms 684 KB Output is correct
10 Correct 413 ms 684 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 2 ms 764 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 0 ms 776 KB Output is correct
16 Correct 333 ms 684 KB Output is correct
17 Correct 317 ms 684 KB Output is correct
18 Correct 350 ms 684 KB Output is correct
19 Correct 312 ms 684 KB Output is correct
20 Correct 318 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 322 ms 940 KB Output is correct
2 Correct 302 ms 1200 KB Output is correct
3 Correct 592 ms 684 KB Output is correct
4 Correct 481 ms 684 KB Output is correct
5 Correct 395 ms 688 KB Output is correct
6 Correct 295 ms 684 KB Output is correct
7 Correct 280 ms 684 KB Output is correct
8 Correct 2 ms 776 KB Output is correct
9 Correct 1 ms 776 KB Output is correct
10 Correct 0 ms 764 KB Output is correct
11 Correct 308 ms 952 KB Output is correct
12 Correct 368 ms 684 KB Output is correct
13 Correct 603 ms 936 KB Output is correct
14 Correct 443 ms 684 KB Output is correct
15 Correct 382 ms 684 KB Output is correct
16 Correct 281 ms 684 KB Output is correct
17 Correct 393 ms 684 KB Output is correct
18 Correct 301 ms 940 KB Output is correct
19 Correct 321 ms 784 KB Output is correct
20 Correct 256 ms 684 KB Output is correct
21 Correct 28 ms 764 KB Output is correct
22 Correct 48 ms 764 KB Output is correct
23 Correct 74 ms 716 KB Output is correct
24 Correct 2 ms 760 KB Output is correct
25 Correct 2 ms 768 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 1 ms 768 KB Output is correct
28 Correct 0 ms 768 KB Output is correct
29 Correct 316 ms 808 KB Output is correct
30 Correct 311 ms 684 KB Output is correct
31 Correct 326 ms 684 KB Output is correct
32 Correct 342 ms 684 KB Output is correct
33 Correct 378 ms 684 KB Output is correct
34 Correct 204 ms 684 KB Output is correct
35 Correct 268 ms 1060 KB Output is correct
36 Correct 322 ms 684 KB Output is correct
37 Correct 290 ms 796 KB Output is correct
38 Correct 355 ms 1044 KB Output is correct
39 Correct 313 ms 792 KB Output is correct
40 Correct 272 ms 796 KB Output is correct
41 Correct 293 ms 788 KB Output is correct
42 Correct 31 ms 688 KB Output is correct
43 Correct 77 ms 760 KB Output is correct
44 Correct 91 ms 684 KB Output is correct
45 Correct 103 ms 760 KB Output is correct
46 Correct 191 ms 684 KB Output is correct
47 Correct 214 ms 684 KB Output is correct
48 Correct 28 ms 1024 KB Output is correct
49 Correct 32 ms 856 KB Output is correct