Submission #1096002

# Submission time Handle Problem Language Result Execution time Memory
1096002 2024-10-03T14:48:26 Z Newtonabc Stations (IOI20_stations) C++14
100 / 100
667 ms 1096 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int tmpcase1,cnt=0,root;
vector<int> adj[N],lb;
void dfs(int u,int p,int lvl){
	if(lvl%2==0) lb[u]=cnt++;
	for(int i=0;i<adj[u].size();i++){
		int v=adj[u][i];
		if(v!=p) dfs(v,u,lvl+1);
	}
	if(lvl%2) lb[u]=cnt++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	lb.resize(n);
	cnt=0;
	for(int i=0;i<n-1;i++){
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	dfs(0,-1,0);
	for(int i=0;i<n;i++) adj[i].clear();
	/*for(int i=0;i<lb.size();i++) cout<<lb[i] <<" ";
	cout<<"\n\n\n";*/
	return lb;
}

int find_next_station(int s, int t, vector<int> c) {
	//for(int i=0;i<c.size();i++) cout<<c[i] <<" ";
	//cout<<c.size();
	//cout<<"\n";
	bool mx=true;
	int tmn=INT_MAX,n=c.size();
	if(c.size()==1) return c[0];
	for(int i=0;i<c.size();i++){
		if(s<c[i]) mx=false;
	}
	if(mx){
		for(int i=n-1;t<s && i>=1;i--) if(t>=c[i]) return c[i];
		return c[0];
	}
	else{
		for(int i=0;t>s && i<n-1;i++) if(t<=c[i]) return c[i];
		return c[n-1];
	}
	
}

Compilation message

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:9:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=0;i<adj[u].size();i++){
      |              ~^~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:36:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for(int i=0;i<c.size();i++){
      |              ~^~~~~~~~~
stations.cpp:34:6: warning: unused variable 'tmn' [-Wunused-variable]
   34 |  int tmn=INT_MAX,n=c.size();
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 402 ms 940 KB Output is correct
2 Correct 345 ms 940 KB Output is correct
3 Correct 625 ms 684 KB Output is correct
4 Correct 453 ms 684 KB Output is correct
5 Correct 465 ms 684 KB Output is correct
6 Correct 316 ms 684 KB Output is correct
7 Correct 293 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
# Verdict Execution time Memory Grader output
1 Correct 306 ms 876 KB Output is correct
2 Correct 405 ms 684 KB Output is correct
3 Correct 605 ms 688 KB Output is correct
4 Correct 444 ms 684 KB Output is correct
5 Correct 434 ms 684 KB Output is correct
6 Correct 336 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 400 ms 940 KB Output is correct
2 Correct 303 ms 940 KB Output is correct
3 Correct 625 ms 684 KB Output is correct
4 Correct 430 ms 684 KB Output is correct
5 Correct 444 ms 684 KB Output is correct
6 Correct 288 ms 684 KB Output is correct
7 Correct 260 ms 796 KB Output is correct
8 Correct 1 ms 760 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 338 ms 800 KB Output is correct
12 Correct 297 ms 1048 KB Output is correct
13 Correct 280 ms 896 KB Output is correct
14 Correct 260 ms 684 KB Output is correct
15 Correct 28 ms 768 KB Output is correct
16 Correct 40 ms 768 KB Output is correct
17 Correct 68 ms 780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 566 ms 688 KB Output is correct
2 Correct 377 ms 684 KB Output is correct
3 Correct 356 ms 684 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 3 ms 776 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 369 ms 940 KB Output is correct
8 Correct 520 ms 684 KB Output is correct
9 Correct 407 ms 684 KB Output is correct
10 Correct 350 ms 684 KB Output is correct
11 Correct 3 ms 772 KB Output is correct
12 Correct 4 ms 764 KB Output is correct
13 Correct 3 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 319 ms 684 KB Output is correct
17 Correct 347 ms 796 KB Output is correct
18 Correct 330 ms 684 KB Output is correct
19 Correct 279 ms 684 KB Output is correct
20 Correct 343 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 361 ms 684 KB Output is correct
2 Correct 309 ms 940 KB Output is correct
3 Correct 602 ms 684 KB Output is correct
4 Correct 451 ms 684 KB Output is correct
5 Correct 420 ms 940 KB Output is correct
6 Correct 301 ms 684 KB Output is correct
7 Correct 305 ms 684 KB Output is correct
8 Correct 1 ms 1028 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 0 ms 776 KB Output is correct
11 Correct 342 ms 684 KB Output is correct
12 Correct 392 ms 684 KB Output is correct
13 Correct 667 ms 684 KB Output is correct
14 Correct 521 ms 684 KB Output is correct
15 Correct 445 ms 684 KB Output is correct
16 Correct 309 ms 856 KB Output is correct
17 Correct 417 ms 684 KB Output is correct
18 Correct 315 ms 1036 KB Output is correct
19 Correct 281 ms 780 KB Output is correct
20 Correct 255 ms 684 KB Output is correct
21 Correct 30 ms 768 KB Output is correct
22 Correct 37 ms 688 KB Output is correct
23 Correct 58 ms 716 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 3 ms 768 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 306 ms 684 KB Output is correct
30 Correct 307 ms 684 KB Output is correct
31 Correct 311 ms 684 KB Output is correct
32 Correct 298 ms 684 KB Output is correct
33 Correct 347 ms 684 KB Output is correct
34 Correct 177 ms 684 KB Output is correct
35 Correct 267 ms 940 KB Output is correct
36 Correct 295 ms 784 KB Output is correct
37 Correct 277 ms 784 KB Output is correct
38 Correct 279 ms 784 KB Output is correct
39 Correct 270 ms 908 KB Output is correct
40 Correct 258 ms 792 KB Output is correct
41 Correct 251 ms 800 KB Output is correct
42 Correct 35 ms 768 KB Output is correct
43 Correct 57 ms 852 KB Output is correct
44 Correct 70 ms 744 KB Output is correct
45 Correct 110 ms 872 KB Output is correct
46 Correct 207 ms 684 KB Output is correct
47 Correct 206 ms 684 KB Output is correct
48 Correct 39 ms 764 KB Output is correct
49 Correct 27 ms 1096 KB Output is correct