Submission #432842

# Submission time Handle Problem Language Result Execution time Memory
432842 2021-06-18T14:07:00 Z charterla Stations (IOI20_stations) C++14
100 / 100
898 ms 796 KB
#include "stations.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

struct Node{
	vector<int> to;
}point[1005];
vector<int> labels;

int num;
void build(int now,int last,int p){
	if(p%2==0)labels[now]=num++;
	
	for(int i=0;i<point[now].to.size();i++){
		int next=point[now].to[i];
		if(next!=last)build(next,now,p+1);
	}
	
	if(p%2==1)labels[now]=num++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	num=0;labels.clear();labels.resize(n);
	for(int i=0;i<n;i++){point[i].to.clear();}
	
	for(int i=0;i<n-1;i++){
		point[u[i]].to.push_back(v[i]);
		point[v[i]].to.push_back(u[i]);
	}
	
	build(0,-1,0);
	//for(int i=0;i<n;i++)cout<<i<<":"<<labels[i]<<" ";cout<<endl;
	return labels;
}

int find_next_station(int s, int t, vector<int> c){
	if(c.size()==1)return c[0];
	
	if(s>c[0]){
		if(t<=c[0] || t>s)return c[0];
		else return *--upper_bound(c.begin(),c.end(),t);
	}
	else{
		if(t<s || t>=c.back())return c.back();
		else return *lower_bound(c.begin(),c.end(),t);
	}
}

Compilation message

stations.cpp: In function 'void build(int, int, int)':
stations.cpp:16:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i=0;i<point[now].to.size();i++){
      |              ~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 556 ms 528 KB Output is correct
2 Correct 479 ms 496 KB Output is correct
3 Correct 894 ms 400 KB Output is correct
4 Correct 599 ms 520 KB Output is correct
5 Correct 601 ms 400 KB Output is correct
6 Correct 427 ms 504 KB Output is correct
7 Correct 447 ms 516 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 466 ms 528 KB Output is correct
2 Correct 511 ms 508 KB Output is correct
3 Correct 887 ms 512 KB Output is correct
4 Correct 617 ms 504 KB Output is correct
5 Correct 589 ms 536 KB Output is correct
6 Correct 472 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 560 ms 616 KB Output is correct
2 Correct 449 ms 648 KB Output is correct
3 Correct 889 ms 400 KB Output is correct
4 Correct 674 ms 512 KB Output is correct
5 Correct 601 ms 520 KB Output is correct
6 Correct 444 ms 528 KB Output is correct
7 Correct 467 ms 500 KB Output is correct
8 Correct 3 ms 472 KB Output is correct
9 Correct 4 ms 476 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 607 ms 512 KB Output is correct
12 Correct 489 ms 752 KB Output is correct
13 Correct 485 ms 632 KB Output is correct
14 Correct 443 ms 528 KB Output is correct
15 Correct 59 ms 596 KB Output is correct
16 Correct 65 ms 528 KB Output is correct
17 Correct 105 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 878 ms 400 KB Output is correct
2 Correct 669 ms 400 KB Output is correct
3 Correct 553 ms 508 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 573 ms 632 KB Output is correct
8 Correct 898 ms 508 KB Output is correct
9 Correct 638 ms 472 KB Output is correct
10 Correct 594 ms 400 KB Output is correct
11 Correct 6 ms 468 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 4 ms 468 KB Output is correct
14 Correct 4 ms 468 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 486 ms 556 KB Output is correct
17 Correct 453 ms 512 KB Output is correct
18 Correct 491 ms 400 KB Output is correct
19 Correct 516 ms 400 KB Output is correct
20 Correct 489 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 504 ms 528 KB Output is correct
2 Correct 451 ms 520 KB Output is correct
3 Correct 857 ms 400 KB Output is correct
4 Correct 663 ms 500 KB Output is correct
5 Correct 582 ms 500 KB Output is correct
6 Correct 434 ms 516 KB Output is correct
7 Correct 418 ms 504 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Correct 436 ms 528 KB Output is correct
12 Correct 537 ms 536 KB Output is correct
13 Correct 830 ms 528 KB Output is correct
14 Correct 661 ms 588 KB Output is correct
15 Correct 608 ms 400 KB Output is correct
16 Correct 440 ms 496 KB Output is correct
17 Correct 560 ms 528 KB Output is correct
18 Correct 449 ms 628 KB Output is correct
19 Correct 441 ms 796 KB Output is correct
20 Correct 435 ms 512 KB Output is correct
21 Correct 55 ms 416 KB Output is correct
22 Correct 61 ms 548 KB Output is correct
23 Correct 106 ms 528 KB Output is correct
24 Correct 7 ms 468 KB Output is correct
25 Correct 7 ms 468 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 4 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 453 ms 416 KB Output is correct
30 Correct 488 ms 400 KB Output is correct
31 Correct 492 ms 512 KB Output is correct
32 Correct 517 ms 400 KB Output is correct
33 Correct 513 ms 512 KB Output is correct
34 Correct 312 ms 528 KB Output is correct
35 Correct 457 ms 528 KB Output is correct
36 Correct 434 ms 632 KB Output is correct
37 Correct 438 ms 648 KB Output is correct
38 Correct 470 ms 624 KB Output is correct
39 Correct 455 ms 620 KB Output is correct
40 Correct 443 ms 612 KB Output is correct
41 Correct 484 ms 756 KB Output is correct
42 Correct 60 ms 600 KB Output is correct
43 Correct 114 ms 620 KB Output is correct
44 Correct 127 ms 528 KB Output is correct
45 Correct 163 ms 508 KB Output is correct
46 Correct 330 ms 528 KB Output is correct
47 Correct 294 ms 528 KB Output is correct
48 Correct 61 ms 676 KB Output is correct
49 Correct 60 ms 656 KB Output is correct