Submission #800498

# Submission time Handle Problem Language Result Execution time Memory
800498 2023-08-01T15:35:40 Z FEDIKUS Stations (IOI20_stations) C++17
100 / 100
798 ms 828 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

const int maxn=1010;
int t=0;
int tin[maxn];
int tout[maxn];
int res[maxn];
vector<int> g[maxn];

void dfs(int node,int d=0,int par=-1){
	tin[node]=t++;
	for(int i:g[node]){
		if(i==par) continue;
		dfs(i,d+1,node);
	}
	tout[node]=t++;
	if(d&1) res[node]=tin[node];
	else res[node]=tout[node];
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(n);
	for(int i=0;i<n;i++) g[i].clear();
	for(int i=0;i<n-1;i++){
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	t=0;
	dfs(0);
	for(int i=0;i<n;i++) labels[i]=res[i];
	vector<int> srt=labels;
	sort(srt.begin(),srt.end());
	for(int i=0;i<n;i++) labels[i]=lower_bound(srt.begin(),srt.end(),labels[i])-srt.begin();
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	int maxi=*max_element(c.begin(),c.end());
	vector<pair<int,int> > decoo(int(c.size())-1);
	if(maxi>s){ // on je in
		int cale=c.back();
		c.pop_back();
		for(int i=0;i<int(c.size());i++) decoo[i].second=c[i];
		int prosli=s;
		for(int i=0;i<int(c.size());i++){
			decoo[i].first=prosli+1;
			prosli=decoo[i].second;
		}
		for(int i=0;i<int(c.size());i++){
			if(decoo[i].first<=t && t<=decoo[i].second) return decoo[i].second;
		}
		return cale;
	}else{ //on je out
		int cale=c.front();
		c.erase(c.begin());
		for(int i=0;i<int(c.size());i++) decoo[i].first=c[i];
		int prosli=s;
		for(int i=int(c.size())-1;i>=0;i--){
			decoo[i].second=prosli-1;
			prosli=decoo[i].first;
		}
		for(int i=0;i<int(c.size());i++){
			if(decoo[i].first<=t && t<=decoo[i].second) return decoo[i].first;
		}
		return cale;
	}
	return c[0];
}
# Verdict Execution time Memory Grader output
1 Correct 457 ms 672 KB Output is correct
2 Correct 354 ms 656 KB Output is correct
3 Correct 798 ms 420 KB Output is correct
4 Correct 505 ms 544 KB Output is correct
5 Correct 513 ms 528 KB Output is correct
6 Correct 422 ms 544 KB Output is correct
7 Correct 407 ms 524 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 3 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 346 ms 616 KB Output is correct
2 Correct 426 ms 568 KB Output is correct
3 Correct 701 ms 660 KB Output is correct
4 Correct 597 ms 672 KB Output is correct
5 Correct 406 ms 736 KB Output is correct
6 Correct 340 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 374 ms 672 KB Output is correct
2 Correct 299 ms 656 KB Output is correct
3 Correct 762 ms 532 KB Output is correct
4 Correct 551 ms 536 KB Output is correct
5 Correct 448 ms 544 KB Output is correct
6 Correct 446 ms 656 KB Output is correct
7 Correct 340 ms 544 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 502 ms 528 KB Output is correct
12 Correct 365 ms 784 KB Output is correct
13 Correct 336 ms 780 KB Output is correct
14 Correct 426 ms 544 KB Output is correct
15 Correct 43 ms 620 KB Output is correct
16 Correct 59 ms 672 KB Output is correct
17 Correct 101 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 671 ms 524 KB Output is correct
2 Correct 583 ms 532 KB Output is correct
3 Correct 484 ms 544 KB Output is correct
4 Correct 1 ms 488 KB Output is correct
5 Correct 3 ms 628 KB Output is correct
6 Correct 0 ms 620 KB Output is correct
7 Correct 468 ms 544 KB Output is correct
8 Correct 590 ms 416 KB Output is correct
9 Correct 618 ms 544 KB Output is correct
10 Correct 553 ms 536 KB Output is correct
11 Correct 2 ms 500 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 4 ms 620 KB Output is correct
14 Correct 2 ms 632 KB Output is correct
15 Correct 1 ms 500 KB Output is correct
16 Correct 448 ms 524 KB Output is correct
17 Correct 430 ms 420 KB Output is correct
18 Correct 399 ms 520 KB Output is correct
19 Correct 433 ms 416 KB Output is correct
20 Correct 436 ms 652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 374 ms 668 KB Output is correct
2 Correct 402 ms 652 KB Output is correct
3 Correct 790 ms 528 KB Output is correct
4 Correct 517 ms 656 KB Output is correct
5 Correct 446 ms 532 KB Output is correct
6 Correct 370 ms 656 KB Output is correct
7 Correct 378 ms 544 KB Output is correct
8 Correct 1 ms 568 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 382 ms 528 KB Output is correct
12 Correct 401 ms 548 KB Output is correct
13 Correct 739 ms 416 KB Output is correct
14 Correct 482 ms 548 KB Output is correct
15 Correct 520 ms 568 KB Output is correct
16 Correct 372 ms 528 KB Output is correct
17 Correct 494 ms 532 KB Output is correct
18 Correct 340 ms 656 KB Output is correct
19 Correct 371 ms 768 KB Output is correct
20 Correct 381 ms 528 KB Output is correct
21 Correct 52 ms 788 KB Output is correct
22 Correct 62 ms 544 KB Output is correct
23 Correct 99 ms 672 KB Output is correct
24 Correct 4 ms 492 KB Output is correct
25 Correct 4 ms 628 KB Output is correct
26 Correct 2 ms 628 KB Output is correct
27 Correct 3 ms 620 KB Output is correct
28 Correct 1 ms 620 KB Output is correct
29 Correct 338 ms 528 KB Output is correct
30 Correct 426 ms 528 KB Output is correct
31 Correct 461 ms 612 KB Output is correct
32 Correct 427 ms 544 KB Output is correct
33 Correct 472 ms 544 KB Output is correct
34 Correct 288 ms 656 KB Output is correct
35 Correct 384 ms 772 KB Output is correct
36 Correct 421 ms 776 KB Output is correct
37 Correct 316 ms 744 KB Output is correct
38 Correct 440 ms 644 KB Output is correct
39 Correct 377 ms 656 KB Output is correct
40 Correct 309 ms 772 KB Output is correct
41 Correct 355 ms 644 KB Output is correct
42 Correct 44 ms 676 KB Output is correct
43 Correct 93 ms 676 KB Output is correct
44 Correct 96 ms 544 KB Output is correct
45 Correct 137 ms 544 KB Output is correct
46 Correct 274 ms 536 KB Output is correct
47 Correct 214 ms 544 KB Output is correct
48 Correct 48 ms 828 KB Output is correct
49 Correct 40 ms 820 KB Output is correct