답안 #320600

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320600 2020-11-09T08:27:16 Z kshitij_sodani 기지국 (IOI20_stations) C++14
0 / 100
901 ms 1076 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.back();



	}











	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){
      |       ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 472 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 587 ms 1032 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 901 ms 1076 KB Output is correct
2 Incorrect 785 ms 864 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 543 ms 992 KB Wrong query response.
2 Halted 0 ms 0 KB -