Submission #321906

# Submission time Handle Problem Language Result Execution time Memory
321906 2020-11-13T13:55:48 Z tigicha Stations (IOI20_stations) C++17
100 / 100
1156 ms 1292 KB
#include<bits/stdc++.h>
using namespace std;
int fix[1005], l;
vector<int>vec[1005], labels;
void dfs(int x, int y){
	fix[x]=1;
	if(y%2==0){
		l++;
		labels[x]=l;
	}
	for(int i=0; i<vec[x].size(); i++)
	if(fix[vec[x][i]]!=1) dfs(vec[x][i], y+1);
	if(y%2==1){
		l++;
		labels[x]=l;
	}
}
std::vector<int> label(int n, int k, std::vector<int>u, std::vector<int>v){
	labels.clear();
	for(int i=0; i<n; i++)
	labels.push_back(-1);
	l=0;
	for(int i=0; i<n; i++){
		vec[i].clear();
		fix[i]=0;
	}
	for(int i=0; i<u.size(); i++){
		vec[u[i]].push_back(v[i]);
		vec[v[i]].push_back(u[i]);
	}
	dfs(0, 0);
	return labels;
}
int find_next_station(int s, int t, std::vector<int>c){
	if(s<c[0]){
	    if(t>s){	
			for(int i=0; i<c.size()-1; i++)
			if(t>c[i]) continue;
			else return c[i];
		}
		return c[c.size()-1];			
	}
	else{
		if(t<s){
			for(int i=c.size()-1; i>0; i--)
			if(t<c[i]) continue;
			else return c[i];
		}
		return c[0];
	}
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:11:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0; i<vec[x].size(); i++)
      |               ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i=0; i<u.size(); i++){
      |               ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    for(int i=0; i<c.size()-1; i++)
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 600 ms 1012 KB Output is correct
2 Correct 486 ms 892 KB Output is correct
3 Correct 995 ms 864 KB Output is correct
4 Correct 703 ms 736 KB Output is correct
5 Correct 646 ms 864 KB Output is correct
6 Correct 478 ms 992 KB Output is correct
7 Correct 511 ms 1112 KB Output is correct
8 Correct 4 ms 864 KB Output is correct
9 Correct 6 ms 884 KB Output is correct
10 Correct 2 ms 884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 596 ms 864 KB Output is correct
2 Correct 639 ms 864 KB Output is correct
3 Correct 1033 ms 916 KB Output is correct
4 Correct 749 ms 748 KB Output is correct
5 Correct 574 ms 864 KB Output is correct
6 Correct 493 ms 1068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 541 ms 864 KB Output is correct
2 Correct 546 ms 1012 KB Output is correct
3 Correct 1156 ms 896 KB Output is correct
4 Correct 672 ms 864 KB Output is correct
5 Correct 655 ms 1132 KB Output is correct
6 Correct 550 ms 1168 KB Output is correct
7 Correct 497 ms 876 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 4 ms 736 KB Output is correct
10 Correct 2 ms 864 KB Output is correct
11 Correct 577 ms 992 KB Output is correct
12 Correct 439 ms 1292 KB Output is correct
13 Correct 557 ms 1012 KB Output is correct
14 Correct 532 ms 736 KB Output is correct
15 Correct 51 ms 1148 KB Output is correct
16 Correct 58 ms 864 KB Output is correct
17 Correct 144 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 930 ms 864 KB Output is correct
2 Correct 803 ms 864 KB Output is correct
3 Correct 651 ms 864 KB Output is correct
4 Correct 3 ms 864 KB Output is correct
5 Correct 5 ms 864 KB Output is correct
6 Correct 2 ms 1020 KB Output is correct
7 Correct 994 ms 864 KB Output is correct
8 Correct 1023 ms 864 KB Output is correct
9 Correct 654 ms 864 KB Output is correct
10 Correct 785 ms 864 KB Output is correct
11 Correct 6 ms 740 KB Output is correct
12 Correct 5 ms 1076 KB Output is correct
13 Correct 6 ms 912 KB Output is correct
14 Correct 5 ms 752 KB Output is correct
15 Correct 2 ms 896 KB Output is correct
16 Correct 539 ms 864 KB Output is correct
17 Correct 502 ms 896 KB Output is correct
18 Correct 587 ms 768 KB Output is correct
19 Correct 546 ms 868 KB Output is correct
20 Correct 644 ms 1164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 657 ms 992 KB Output is correct
2 Correct 449 ms 1016 KB Output is correct
3 Correct 1027 ms 884 KB Output is correct
4 Correct 858 ms 768 KB Output is correct
5 Correct 811 ms 1000 KB Output is correct
6 Correct 527 ms 896 KB Output is correct
7 Correct 494 ms 992 KB Output is correct
8 Correct 3 ms 1004 KB Output is correct
9 Correct 5 ms 864 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 625 ms 840 KB Output is correct
12 Correct 579 ms 804 KB Output is correct
13 Correct 1103 ms 896 KB Output is correct
14 Correct 706 ms 932 KB Output is correct
15 Correct 662 ms 864 KB Output is correct
16 Correct 582 ms 864 KB Output is correct
17 Correct 678 ms 864 KB Output is correct
18 Correct 497 ms 1008 KB Output is correct
19 Correct 575 ms 1160 KB Output is correct
20 Correct 550 ms 748 KB Output is correct
21 Correct 74 ms 884 KB Output is correct
22 Correct 99 ms 736 KB Output is correct
23 Correct 137 ms 864 KB Output is correct
24 Correct 6 ms 864 KB Output is correct
25 Correct 6 ms 904 KB Output is correct
26 Correct 6 ms 948 KB Output is correct
27 Correct 6 ms 872 KB Output is correct
28 Correct 2 ms 736 KB Output is correct
29 Correct 529 ms 736 KB Output is correct
30 Correct 492 ms 896 KB Output is correct
31 Correct 522 ms 896 KB Output is correct
32 Correct 630 ms 864 KB Output is correct
33 Correct 534 ms 864 KB Output is correct
34 Correct 381 ms 992 KB Output is correct
35 Correct 550 ms 1160 KB Output is correct
36 Correct 635 ms 1012 KB Output is correct
37 Correct 627 ms 1120 KB Output is correct
38 Correct 460 ms 896 KB Output is correct
39 Correct 558 ms 916 KB Output is correct
40 Correct 569 ms 1012 KB Output is correct
41 Correct 644 ms 968 KB Output is correct
42 Correct 92 ms 864 KB Output is correct
43 Correct 111 ms 964 KB Output is correct
44 Correct 184 ms 904 KB Output is correct
45 Correct 138 ms 992 KB Output is correct
46 Correct 442 ms 864 KB Output is correct
47 Correct 270 ms 904 KB Output is correct
48 Correct 75 ms 864 KB Output is correct
49 Correct 71 ms 864 KB Output is correct