Submission #955093

# Submission time Handle Problem Language Result Execution time Memory
955093 2024-03-29T11:22:54 Z Trisanu_Das Stations (IOI20_stations) C++17
100 / 100
600 ms 1408 KB
#include <bits/stdc++.h>
#define y e[x][i]
using namespace std;
typedef vector<int> vec;
void dfs(int x,int fa,bool d,int&sum,const vector<vec> &e,vec&res){
	if(d) res[x]=sum++;
	for(int i=0;i<e[x].size();i++)
		if(y!=fa) dfs(y,x,d^1,sum,e,res);
	if(!d) res[x]=sum++;
}
vec label(int n,int k,vec u,vec v){
	vec res(n);vector<vec> e(n,vec());
	for(int i=0;i<n-1;i++) {e[u[i]].push_back(v[i]);e[v[i]].push_back(u[i]);}
	int sum=0;dfs(0,-1,1,sum,e,res);return res;
}
int find_next_station(int s,int t,vec c){
	if(c[0]>s){
		if(t<s||c.back()<t) return c.back();
		return *lower_bound(c.begin(),c.end(),t);
	}
	if(t<c[0]||s<t) return c[0];
	return *(upper_bound(c.begin(),c.end(),t)-1);
}

Compilation message

stations.cpp: In function 'void dfs(int, int, bool, int&, const std::vector<std::vector<int> >&, vec&)':
stations.cpp:7:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i=0;i<e[x].size();i++)
      |              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 330 ms 932 KB Output is correct
2 Correct 291 ms 956 KB Output is correct
3 Correct 546 ms 684 KB Output is correct
4 Correct 463 ms 684 KB Output is correct
5 Correct 380 ms 684 KB Output is correct
6 Correct 295 ms 928 KB Output is correct
7 Correct 315 ms 692 KB Output is correct
8 Correct 2 ms 756 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 1 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 270 ms 848 KB Output is correct
2 Correct 309 ms 796 KB Output is correct
3 Correct 593 ms 700 KB Output is correct
4 Correct 438 ms 708 KB Output is correct
5 Correct 377 ms 684 KB Output is correct
6 Correct 305 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 318 ms 932 KB Output is correct
2 Correct 278 ms 956 KB Output is correct
3 Correct 597 ms 684 KB Output is correct
4 Correct 412 ms 684 KB Output is correct
5 Correct 415 ms 684 KB Output is correct
6 Correct 307 ms 920 KB Output is correct
7 Correct 276 ms 684 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 407 ms 684 KB Output is correct
12 Correct 309 ms 944 KB Output is correct
13 Correct 303 ms 1280 KB Output is correct
14 Correct 261 ms 684 KB Output is correct
15 Correct 33 ms 768 KB Output is correct
16 Correct 36 ms 900 KB Output is correct
17 Correct 58 ms 940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 583 ms 684 KB Output is correct
2 Correct 474 ms 684 KB Output is correct
3 Correct 403 ms 684 KB Output is correct
4 Correct 1 ms 1272 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 372 ms 684 KB Output is correct
8 Correct 600 ms 684 KB Output is correct
9 Correct 407 ms 684 KB Output is correct
10 Correct 390 ms 684 KB Output is correct
11 Correct 3 ms 768 KB Output is correct
12 Correct 3 ms 772 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 0 ms 768 KB Output is correct
16 Correct 286 ms 684 KB Output is correct
17 Correct 353 ms 696 KB Output is correct
18 Correct 360 ms 692 KB Output is correct
19 Correct 335 ms 700 KB Output is correct
20 Correct 303 ms 708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 371 ms 928 KB Output is correct
2 Correct 295 ms 920 KB Output is correct
3 Correct 548 ms 684 KB Output is correct
4 Correct 446 ms 684 KB Output is correct
5 Correct 365 ms 684 KB Output is correct
6 Correct 282 ms 1196 KB Output is correct
7 Correct 267 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 1 ms 764 KB Output is correct
11 Correct 271 ms 1100 KB Output is correct
12 Correct 355 ms 820 KB Output is correct
13 Correct 582 ms 684 KB Output is correct
14 Correct 428 ms 688 KB Output is correct
15 Correct 376 ms 684 KB Output is correct
16 Correct 296 ms 684 KB Output is correct
17 Correct 372 ms 684 KB Output is correct
18 Correct 345 ms 1168 KB Output is correct
19 Correct 332 ms 1272 KB Output is correct
20 Correct 295 ms 684 KB Output is correct
21 Correct 30 ms 764 KB Output is correct
22 Correct 36 ms 852 KB Output is correct
23 Correct 58 ms 904 KB Output is correct
24 Correct 4 ms 768 KB Output is correct
25 Correct 3 ms 768 KB Output is correct
26 Correct 3 ms 760 KB Output is correct
27 Correct 2 ms 764 KB Output is correct
28 Correct 0 ms 764 KB Output is correct
29 Correct 354 ms 684 KB Output is correct
30 Correct 340 ms 684 KB Output is correct
31 Correct 311 ms 708 KB Output is correct
32 Correct 335 ms 684 KB Output is correct
33 Correct 321 ms 684 KB Output is correct
34 Correct 211 ms 896 KB Output is correct
35 Correct 303 ms 1400 KB Output is correct
36 Correct 304 ms 1180 KB Output is correct
37 Correct 332 ms 952 KB Output is correct
38 Correct 267 ms 1112 KB Output is correct
39 Correct 265 ms 968 KB Output is correct
40 Correct 310 ms 1148 KB Output is correct
41 Correct 279 ms 1204 KB Output is correct
42 Correct 36 ms 920 KB Output is correct
43 Correct 78 ms 860 KB Output is correct
44 Correct 92 ms 884 KB Output is correct
45 Correct 106 ms 908 KB Output is correct
46 Correct 217 ms 856 KB Output is correct
47 Correct 186 ms 884 KB Output is correct
48 Correct 31 ms 1196 KB Output is correct
49 Correct 33 ms 1408 KB Output is correct