Submission #831153

# Submission time Handle Problem Language Result Execution time Memory
831153 2023-08-19T19:48:32 Z Baytoro Stations (IOI20_stations) C++17
100 / 100
819 ms 752 KB
#include "stations.h"
//#include "stub.cpp"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> label(int n, int k,vector<int> u, vector<int> v) {
	vector<vector<int>> g(n);
	for(int i=0;i<n-1;i++){
		g[u[i]].pb(v[i]);
		g[v[i]].pb(u[i]);
	}
	vector<int> ans(n),d(n,-1);
	int cnt=0;
	function<void(int)> dfs=[&](int x){
		if(d[x]%2==0) ans[x]=cnt++;
		for(auto it: g[x]){
			if(d[it]!=-1) continue;
			d[it]=d[x]+1;
			dfs(it);
		}
		if(d[x]%2) ans[x]=cnt++;
	};
	d[0]=0;
	dfs(0);
	return ans;
}

int find_next_station(int s, int t, vector<int> c) {
	if(s>=c.back()){
		if(t>s || t<c[0]) return c[0];
		return c[int(lower_bound(c.begin(),c.end(),t+1)-c.begin())-1];
	}
	else{
		if(t<s || t>c.back()) return c.back();
		return c[int(lower_bound(c.begin(),c.end(),t)-c.begin())];
	}
}
# Verdict Execution time Memory Grader output
1 Correct 446 ms 672 KB Output is correct
2 Correct 405 ms 636 KB Output is correct
3 Correct 640 ms 508 KB Output is correct
4 Correct 571 ms 504 KB Output is correct
5 Correct 478 ms 512 KB Output is correct
6 Correct 404 ms 628 KB Output is correct
7 Correct 311 ms 628 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 2 ms 480 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 416 ms 504 KB Output is correct
2 Correct 463 ms 504 KB Output is correct
3 Correct 659 ms 500 KB Output is correct
4 Correct 430 ms 504 KB Output is correct
5 Correct 494 ms 500 KB Output is correct
6 Correct 303 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 362 ms 624 KB Output is correct
2 Correct 304 ms 636 KB Output is correct
3 Correct 757 ms 420 KB Output is correct
4 Correct 438 ms 500 KB Output is correct
5 Correct 506 ms 420 KB Output is correct
6 Correct 333 ms 632 KB Output is correct
7 Correct 284 ms 552 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
11 Correct 421 ms 420 KB Output is correct
12 Correct 335 ms 704 KB Output is correct
13 Correct 337 ms 640 KB Output is correct
14 Correct 305 ms 544 KB Output is correct
15 Correct 38 ms 492 KB Output is correct
16 Correct 56 ms 572 KB Output is correct
17 Correct 82 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 602 ms 416 KB Output is correct
2 Correct 589 ms 420 KB Output is correct
3 Correct 422 ms 500 KB Output is correct
4 Correct 1 ms 500 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 0 ms 492 KB Output is correct
7 Correct 563 ms 500 KB Output is correct
8 Correct 681 ms 508 KB Output is correct
9 Correct 535 ms 416 KB Output is correct
10 Correct 421 ms 420 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 3 ms 488 KB Output is correct
13 Correct 2 ms 488 KB Output is correct
14 Correct 2 ms 500 KB Output is correct
15 Correct 1 ms 500 KB Output is correct
16 Correct 349 ms 420 KB Output is correct
17 Correct 436 ms 420 KB Output is correct
18 Correct 376 ms 564 KB Output is correct
19 Correct 441 ms 416 KB Output is correct
20 Correct 438 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 460 ms 628 KB Output is correct
2 Correct 383 ms 624 KB Output is correct
3 Correct 694 ms 508 KB Output is correct
4 Correct 633 ms 504 KB Output is correct
5 Correct 525 ms 500 KB Output is correct
6 Correct 418 ms 548 KB Output is correct
7 Correct 419 ms 504 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 325 ms 544 KB Output is correct
12 Correct 461 ms 556 KB Output is correct
13 Correct 819 ms 500 KB Output is correct
14 Correct 533 ms 504 KB Output is correct
15 Correct 490 ms 416 KB Output is correct
16 Correct 331 ms 548 KB Output is correct
17 Correct 433 ms 504 KB Output is correct
18 Correct 306 ms 752 KB Output is correct
19 Correct 446 ms 620 KB Output is correct
20 Correct 321 ms 500 KB Output is correct
21 Correct 31 ms 492 KB Output is correct
22 Correct 54 ms 544 KB Output is correct
23 Correct 90 ms 544 KB Output is correct
24 Correct 3 ms 500 KB Output is correct
25 Correct 4 ms 492 KB Output is correct
26 Correct 2 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 367 ms 420 KB Output is correct
30 Correct 460 ms 420 KB Output is correct
31 Correct 311 ms 420 KB Output is correct
32 Correct 309 ms 416 KB Output is correct
33 Correct 470 ms 508 KB Output is correct
34 Correct 216 ms 544 KB Output is correct
35 Correct 330 ms 588 KB Output is correct
36 Correct 388 ms 740 KB Output is correct
37 Correct 383 ms 628 KB Output is correct
38 Correct 299 ms 664 KB Output is correct
39 Correct 343 ms 588 KB Output is correct
40 Correct 325 ms 632 KB Output is correct
41 Correct 303 ms 636 KB Output is correct
42 Correct 55 ms 572 KB Output is correct
43 Correct 73 ms 544 KB Output is correct
44 Correct 78 ms 500 KB Output is correct
45 Correct 104 ms 544 KB Output is correct
46 Correct 194 ms 512 KB Output is correct
47 Correct 258 ms 500 KB Output is correct
48 Correct 59 ms 600 KB Output is correct
49 Correct 40 ms 676 KB Output is correct