답안 #308614

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308614 2020-10-01T15:07:07 Z Peacher29 기지국 (IOI20_stations) C++14
0 / 100
896 ms 1024 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

class pont{
public:
	vector<int> v;
	int id;
	bool volt = 0;
	bool mely;
	void dfs(bool mely);
};

vector<pont> p;

int dd = -1;

void pont::dfs(bool mely){
	if(!volt){
		this->mely=mely;
		volt=1;
		if(mely)
		id=++dd;
		for(int i : v){
			p[i].dfs(!mely);
		}
		if(!mely)
		id=++dd;
	}
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	dd=-1;
	p.clear();
	p.resize(n);
	for(int i=0;i<n-1;i++){
		p[u[i]].v.push_back(v[i]);
		p[v[i]].v.push_back(u[i]);
	}
	p[0].dfs(0);
	vector<int> er(n);
	for(int i=0;i<n;i++){
		er[i] = p[i].mely*2000+p[i].id;
	}
	return er;
}

bool contains(int mi, int mit){
	return mi/2000 <= mit/2000 && mit%2000 <= mi%2000;
}

int find_next_station(int s, int t, vector<int> c) {
	sort(c.begin(), c.end());
	for(int i : c){
		if(i==t) return t;
	}
	if(s/2000){
		if(t%2000<s%2000 || (c.size()>1 && c[c.size()-2]%2000 < t%2000)){
			return c.back();
		} else {
			for(int i=0;i<c.size()-1; i++){
				if(t%2000<c[i]%2000){
					return c[i];
				}
			}
			exit(255);
			//return c[c.size()-2];
		}
	} else {
		if(s%2000<t%2000 || (t%2000 < c[0]%2000)){
			return c[0];
		} else {
			for(int i=0;i<c.size()-1; i++){
				if(t%2000<c[i]%2000){
					return c[i-1]; 
				}
			}
			exit(255);
			//return c[c.size()-1];
		}

	}
}
/*
int main(){
	int m;
	while(1){
		cin >> m;
		cout << find_next_station(10,m,{2000,2009});
	}
return 0;
}*/

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:62:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |    for(int i=0;i<c.size()-1; i++){
      |                ~^~~~~~~~~~~
stations.cpp:74:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |    for(int i=0;i<c.size()-1; i++){
      |                ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 504 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2003
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 496 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2000
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 1024 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 896 ms 640 KB Output is correct
2 Runtime error 2 ms 644 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1024 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -