Submission #396254

# Submission time Handle Problem Language Result Execution time Memory
396254 2021-04-29T15:42:42 Z faresbasbs Stations (IOI20_stations) C++14
100 / 100
1124 ms 844 KB
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;

void dfs(int curr , int par , int hi , vector<vector<int>> &graph , int &cnt , vector<int> &ret){
	if(hi%2 == 0){
		ret[curr] = cnt;
		cnt += 1;
	}
	for(auto i : graph[curr]){
		if(i == par){
			continue;
		}
		dfs(i,curr,hi+1,graph,cnt,ret);
	}
	if(hi%2 == 1){
		ret[curr] = cnt;
		cnt += 1;
	}
}

vector<int> label(int n , int k , vector<int> u , vector<int> v){
	vector<vector<int>> graph(1001);
	int cnt = 0;
	for(int i = 0 ; i < u.size() ; i += 1){
		graph[u[i]].push_back(v[i]);
		graph[v[i]].push_back(u[i]);
	}
	vector<int> labels(n);
	dfs(0,0,0,graph,cnt,labels);
	return labels;
}

int find_next_station(int s , int t , vector<int> c){
	sort(c.begin(),c.end());
	if(c.size() == 1){
		return c[0];
	}
	if(s < c[0]){
		if(t >= s && t <= c[c.size()-2]){
			for(int i = 0 ; i < c.size() ; i += 1){
				if(t <= c[i]){
					return c[i];
				}
			}
		}
		return c.back();
	}else{
		if(t <= s && t >= c[1]){
			for(int i = c.size()-1 ; i >= 0 ; i -= 1){
				if(t >= c[i]){
					return c[i];
				}
			}
		}
		return c[0];
	}
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i = 0 ; i < u.size() ; i += 1){
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |    for(int i = 0 ; i < c.size() ; i += 1){
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 632 ms 704 KB Output is correct
2 Correct 632 ms 620 KB Output is correct
3 Correct 978 ms 496 KB Output is correct
4 Correct 833 ms 520 KB Output is correct
5 Correct 687 ms 528 KB Output is correct
6 Correct 575 ms 688 KB Output is correct
7 Correct 452 ms 588 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 583 ms 528 KB Output is correct
2 Correct 695 ms 492 KB Output is correct
3 Correct 1003 ms 656 KB Output is correct
4 Correct 733 ms 660 KB Output is correct
5 Correct 648 ms 528 KB Output is correct
6 Correct 465 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 616 ms 656 KB Output is correct
2 Correct 533 ms 656 KB Output is correct
3 Correct 990 ms 528 KB Output is correct
4 Correct 948 ms 528 KB Output is correct
5 Correct 817 ms 620 KB Output is correct
6 Correct 622 ms 616 KB Output is correct
7 Correct 564 ms 720 KB Output is correct
8 Correct 3 ms 800 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 806 ms 492 KB Output is correct
12 Correct 695 ms 700 KB Output is correct
13 Correct 594 ms 756 KB Output is correct
14 Correct 604 ms 580 KB Output is correct
15 Correct 70 ms 528 KB Output is correct
16 Correct 90 ms 528 KB Output is correct
17 Correct 142 ms 732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1124 ms 612 KB Output is correct
2 Correct 840 ms 496 KB Output is correct
3 Correct 686 ms 532 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 6 ms 600 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 636 ms 528 KB Output is correct
8 Correct 1095 ms 480 KB Output is correct
9 Correct 946 ms 556 KB Output is correct
10 Correct 560 ms 472 KB Output is correct
11 Correct 8 ms 604 KB Output is correct
12 Correct 6 ms 716 KB Output is correct
13 Correct 5 ms 600 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 2 ms 600 KB Output is correct
16 Correct 523 ms 492 KB Output is correct
17 Correct 610 ms 488 KB Output is correct
18 Correct 509 ms 604 KB Output is correct
19 Correct 649 ms 528 KB Output is correct
20 Correct 558 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 607 ms 784 KB Output is correct
2 Correct 442 ms 616 KB Output is correct
3 Correct 1093 ms 472 KB Output is correct
4 Correct 717 ms 488 KB Output is correct
5 Correct 724 ms 472 KB Output is correct
6 Correct 469 ms 844 KB Output is correct
7 Correct 555 ms 492 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 4 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 583 ms 488 KB Output is correct
12 Correct 685 ms 640 KB Output is correct
13 Correct 1037 ms 488 KB Output is correct
14 Correct 908 ms 472 KB Output is correct
15 Correct 807 ms 528 KB Output is correct
16 Correct 554 ms 488 KB Output is correct
17 Correct 632 ms 548 KB Output is correct
18 Correct 545 ms 744 KB Output is correct
19 Correct 516 ms 696 KB Output is correct
20 Correct 626 ms 612 KB Output is correct
21 Correct 81 ms 548 KB Output is correct
22 Correct 88 ms 604 KB Output is correct
23 Correct 145 ms 492 KB Output is correct
24 Correct 5 ms 600 KB Output is correct
25 Correct 5 ms 528 KB Output is correct
26 Correct 5 ms 676 KB Output is correct
27 Correct 5 ms 656 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 653 ms 488 KB Output is correct
30 Correct 545 ms 528 KB Output is correct
31 Correct 582 ms 528 KB Output is correct
32 Correct 574 ms 488 KB Output is correct
33 Correct 644 ms 600 KB Output is correct
34 Correct 404 ms 752 KB Output is correct
35 Correct 455 ms 688 KB Output is correct
36 Correct 613 ms 624 KB Output is correct
37 Correct 534 ms 580 KB Output is correct
38 Correct 621 ms 508 KB Output is correct
39 Correct 639 ms 584 KB Output is correct
40 Correct 470 ms 680 KB Output is correct
41 Correct 536 ms 576 KB Output is correct
42 Correct 76 ms 528 KB Output is correct
43 Correct 144 ms 572 KB Output is correct
44 Correct 203 ms 528 KB Output is correct
45 Correct 218 ms 528 KB Output is correct
46 Correct 477 ms 568 KB Output is correct
47 Correct 372 ms 528 KB Output is correct
48 Correct 70 ms 716 KB Output is correct
49 Correct 46 ms 656 KB Output is correct