Submission #600826

# Submission time Handle Problem Language Result Execution time Memory
600826 2022-07-21T08:06:00 Z MrBrionix Stations (IOI20_stations) C++14
100 / 100
1214 ms 768 KB
#include<bits/stdc++.h>
using namespace std;

vector<int> grafo[1005];
int val[1005],tt;

void dfs(int nodo, int mode, int last){
	if(mode==0)val[nodo]=tt++;
	
	for(auto i : grafo[nodo]){
		if(i!=last)dfs(i,mode^1,nodo);
	}
	
	if(mode==1)val[nodo]=tt++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	
	for(int i=0;i<n;i++)grafo[i].clear();
	tt=0;
	
	for(int i=0;i<n-1;i++){
		grafo[u[i]].push_back(v[i]);
		grafo[v[i]].push_back(u[i]);
	}
	
	dfs(0,0,-1);
	
	for (int i = 0; i < n; i++) {
		//cout<<i<<" "<<val[i]<<"\n";
		labels[i] = val[i];
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	bool mode;
	if(c[0]<s)mode=1;
	else mode=0;
	
	
	if(mode){
		int last=s;
		for(int i=c.size()-1;i>0;i--){
			if(t>=c[i] && t<last)return c[i];
			last=c[i];           
		}
		return c[0];
	}else{
		int last=s;
		int st;
		if(s==0)st=c.size();
		else st=c.size()-1;
		
		for(int i=0;i<st;i++){
			if(t>last && t<=c[i])return c[i];
			last=c[i];
		}
		return c[c.size()-1];
	}	
}
# Verdict Execution time Memory Grader output
1 Correct 494 ms 680 KB Output is correct
2 Correct 457 ms 704 KB Output is correct
3 Correct 813 ms 420 KB Output is correct
4 Correct 617 ms 532 KB Output is correct
5 Correct 536 ms 536 KB Output is correct
6 Correct 392 ms 536 KB Output is correct
7 Correct 452 ms 528 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 3 ms 500 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 452 ms 524 KB Output is correct
2 Correct 567 ms 536 KB Output is correct
3 Correct 755 ms 416 KB Output is correct
4 Correct 601 ms 420 KB Output is correct
5 Correct 537 ms 536 KB Output is correct
6 Correct 426 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 515 ms 536 KB Output is correct
2 Correct 385 ms 648 KB Output is correct
3 Correct 903 ms 416 KB Output is correct
4 Correct 619 ms 416 KB Output is correct
5 Correct 617 ms 416 KB Output is correct
6 Correct 461 ms 664 KB Output is correct
7 Correct 462 ms 532 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 500 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 549 ms 524 KB Output is correct
12 Correct 429 ms 640 KB Output is correct
13 Correct 453 ms 768 KB Output is correct
14 Correct 485 ms 544 KB Output is correct
15 Correct 57 ms 576 KB Output is correct
16 Correct 74 ms 596 KB Output is correct
17 Correct 100 ms 732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 922 ms 416 KB Output is correct
2 Correct 671 ms 528 KB Output is correct
3 Correct 628 ms 532 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 5 ms 624 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 570 ms 420 KB Output is correct
8 Correct 1214 ms 416 KB Output is correct
9 Correct 708 ms 420 KB Output is correct
10 Correct 747 ms 416 KB Output is correct
11 Correct 6 ms 492 KB Output is correct
12 Correct 5 ms 492 KB Output is correct
13 Correct 3 ms 492 KB Output is correct
14 Correct 4 ms 492 KB Output is correct
15 Correct 2 ms 488 KB Output is correct
16 Correct 504 ms 532 KB Output is correct
17 Correct 636 ms 528 KB Output is correct
18 Correct 535 ms 416 KB Output is correct
19 Correct 543 ms 416 KB Output is correct
20 Correct 523 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 562 ms 660 KB Output is correct
2 Correct 510 ms 528 KB Output is correct
3 Correct 908 ms 508 KB Output is correct
4 Correct 641 ms 532 KB Output is correct
5 Correct 686 ms 516 KB Output is correct
6 Correct 535 ms 528 KB Output is correct
7 Correct 403 ms 532 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 4 ms 512 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 439 ms 656 KB Output is correct
12 Correct 625 ms 524 KB Output is correct
13 Correct 1146 ms 448 KB Output is correct
14 Correct 658 ms 416 KB Output is correct
15 Correct 564 ms 416 KB Output is correct
16 Correct 531 ms 536 KB Output is correct
17 Correct 552 ms 420 KB Output is correct
18 Correct 435 ms 640 KB Output is correct
19 Correct 419 ms 652 KB Output is correct
20 Correct 450 ms 524 KB Output is correct
21 Correct 45 ms 572 KB Output is correct
22 Correct 63 ms 604 KB Output is correct
23 Correct 93 ms 728 KB Output is correct
24 Correct 5 ms 492 KB Output is correct
25 Correct 6 ms 492 KB Output is correct
26 Correct 4 ms 492 KB Output is correct
27 Correct 2 ms 500 KB Output is correct
28 Correct 2 ms 564 KB Output is correct
29 Correct 569 ms 532 KB Output is correct
30 Correct 525 ms 420 KB Output is correct
31 Correct 470 ms 528 KB Output is correct
32 Correct 594 ms 532 KB Output is correct
33 Correct 438 ms 420 KB Output is correct
34 Correct 293 ms 548 KB Output is correct
35 Correct 427 ms 672 KB Output is correct
36 Correct 426 ms 548 KB Output is correct
37 Correct 390 ms 756 KB Output is correct
38 Correct 445 ms 640 KB Output is correct
39 Correct 441 ms 648 KB Output is correct
40 Correct 399 ms 656 KB Output is correct
41 Correct 427 ms 656 KB Output is correct
42 Correct 51 ms 544 KB Output is correct
43 Correct 106 ms 608 KB Output is correct
44 Correct 142 ms 540 KB Output is correct
45 Correct 162 ms 536 KB Output is correct
46 Correct 272 ms 548 KB Output is correct
47 Correct 293 ms 536 KB Output is correct
48 Correct 60 ms 700 KB Output is correct
49 Correct 48 ms 672 KB Output is correct