Submission #320604

# Submission time Handle Problem Language Result Execution time Memory
320604 2020-11-09T08:31:45 Z kshitij_sodani Stations (IOI20_stations) C++14
76 / 100
1097 ms 1388 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n'



#include "stations.h"

vector<int> adj[1001];
int co=0;
int st[1001];
int endd[1001];
int levv[1001];
int nn;
void dfs(int no,int par=-1,int levv=0){
	st[no]=co;
	co++;
	for(auto j:adj[no]){
		if(j!=par){
			dfs(j,no,levv+1);
		}
	}

	if(levv%2==1){
		st[no]=co;
	}
	co++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	nn=n;
	for(int i=0;i<n;i++){
		adj[i].clear();
	}
	co=0;
	for(int i=0;i<n-1;i++){
		adj[u[i]].pb(v[i]);
		adj[v[i]].pb(u[i]);
	}
	dfs(0);
	vector<int> ans;
	for(int i=0;i<n;i++){
		ans.pb(st[i]);
	//	cout<<st[i];
	}
	//cout<<endl;




	return ans;
}

int find_next_station(int s, int t, std::vector<int> c) {
	
	if(c.size()==1){
		return c[0];
	}


	sort(c.begin(),c.end());
	/*vector<int> cc;
	for(auto j:c){
		if(j>=1000){
			cc.pb(j-1000);
		}
		else{
			cc.pb(j);
		}
	}*/
	if(s<c[0]){
		int pre=s-1;

		for(int i=0;i<c.size()-1;i++){
			int la=0;

			if(i==0){
				la=s;
			}
			else{
				la=c[i-1]+1;
			}
			if(t<=c[i] and t>=la){
				return c[i];
			}
		}
		return c.back();

	}
	else{
		for(int i=c.size()-1;i>0;i--){
			int la=0;
			if(i==c.size()-1){
				la=s;
			}
			else{
				la=c[i+1]-1;
			}
			if(t<=la and t>=c[i]){
				return c[i];
			}
		}
		return c[0];



	}











	return c[0];
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:78:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |   for(int i=0;i<c.size()-1;i++){
      |               ~^~~~~~~~~~~
stations.cpp:76:7: warning: unused variable 'pre' [-Wunused-variable]
   76 |   int pre=s-1;
      |       ^~~
stations.cpp:97:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |    if(i==c.size()-1){
      |       ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 488 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 476 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 501 ms 1052 KB Output is correct
2 Correct 491 ms 1044 KB Output is correct
3 Correct 1029 ms 864 KB Output is correct
4 Correct 673 ms 944 KB Output is correct
5 Correct 712 ms 944 KB Output is correct
6 Correct 541 ms 1072 KB Output is correct
7 Correct 547 ms 1212 KB Output is correct
8 Correct 3 ms 988 KB Output is correct
9 Correct 5 ms 736 KB Output is correct
10 Correct 1 ms 736 KB Output is correct
11 Correct 569 ms 896 KB Output is correct
12 Correct 547 ms 1072 KB Output is correct
13 Correct 562 ms 956 KB Output is correct
14 Correct 575 ms 736 KB Output is correct
15 Correct 56 ms 944 KB Output is correct
16 Correct 67 ms 736 KB Output is correct
17 Correct 108 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 919 ms 948 KB Output is correct
2 Correct 713 ms 948 KB Output is correct
3 Correct 700 ms 864 KB Output is correct
4 Correct 3 ms 736 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 2 ms 1068 KB Output is correct
7 Correct 625 ms 992 KB Output is correct
8 Correct 923 ms 936 KB Output is correct
9 Correct 730 ms 992 KB Output is correct
10 Correct 619 ms 856 KB Output is correct
11 Correct 5 ms 944 KB Output is correct
12 Correct 5 ms 736 KB Output is correct
13 Correct 6 ms 864 KB Output is correct
14 Correct 4 ms 1072 KB Output is correct
15 Correct 2 ms 864 KB Output is correct
16 Correct 621 ms 864 KB Output is correct
17 Correct 631 ms 944 KB Output is correct
18 Correct 508 ms 864 KB Output is correct
19 Correct 619 ms 1068 KB Output is correct
20 Correct 626 ms 1084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 656 ms 864 KB Partially correct
2 Partially correct 551 ms 992 KB Partially correct
3 Correct 1097 ms 1100 KB Output is correct
4 Correct 773 ms 944 KB Output is correct
5 Correct 638 ms 736 KB Output is correct
6 Partially correct 507 ms 1064 KB Partially correct
7 Partially correct 433 ms 1120 KB Partially correct
8 Correct 3 ms 992 KB Output is correct
9 Correct 5 ms 736 KB Output is correct
10 Correct 1 ms 904 KB Output is correct
11 Partially correct 448 ms 880 KB Partially correct
12 Partially correct 506 ms 872 KB Partially correct
13 Correct 890 ms 944 KB Output is correct
14 Correct 733 ms 1108 KB Output is correct
15 Correct 650 ms 736 KB Output is correct
16 Partially correct 543 ms 736 KB Partially correct
17 Correct 684 ms 864 KB Output is correct
18 Partially correct 524 ms 864 KB Partially correct
19 Partially correct 498 ms 1388 KB Partially correct
20 Partially correct 490 ms 736 KB Partially correct
21 Correct 65 ms 944 KB Output is correct
22 Partially correct 73 ms 864 KB Partially correct
23 Partially correct 130 ms 884 KB Partially correct
24 Correct 7 ms 864 KB Output is correct
25 Correct 7 ms 732 KB Output is correct
26 Correct 6 ms 736 KB Output is correct
27 Correct 4 ms 864 KB Output is correct
28 Correct 2 ms 864 KB Output is correct
29 Correct 569 ms 864 KB Output is correct
30 Correct 547 ms 864 KB Output is correct
31 Correct 531 ms 864 KB Output is correct
32 Correct 594 ms 940 KB Output is correct
33 Correct 554 ms 944 KB Output is correct
34 Partially correct 324 ms 864 KB Partially correct
35 Partially correct 449 ms 860 KB Partially correct
36 Partially correct 452 ms 1048 KB Partially correct
37 Partially correct 594 ms 996 KB Partially correct
38 Partially correct 473 ms 1080 KB Partially correct
39 Partially correct 566 ms 1172 KB Partially correct
40 Partially correct 501 ms 1036 KB Partially correct
41 Partially correct 439 ms 976 KB Partially correct
42 Partially correct 72 ms 736 KB Partially correct
43 Partially correct 101 ms 980 KB Partially correct
44 Partially correct 147 ms 1112 KB Partially correct
45 Partially correct 186 ms 984 KB Partially correct
46 Partially correct 337 ms 864 KB Partially correct
47 Partially correct 301 ms 992 KB Partially correct
48 Partially correct 81 ms 992 KB Partially correct
49 Partially correct 71 ms 1004 KB Partially correct