답안 #321597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321597 2020-11-12T20:21:36 Z keta_tsimakuridze 기지국 (IOI20_stations) C++14
0 / 100
898 ms 896 KB
#include <cstdio>
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int fix[N],timer;
 vector<int> V[N],labels;
void dfs(int u,int h){
	fix[u]=1;
	
	if(h%2==0) timer++,labels[u]=timer;
	for(int i=0;i<V[u].size();i++){
		if(!fix[V[u][i]]){
			dfs(V[u][i],h+1);
		}
	}
	if(h%2) timer++,labels[u]=timer;//cout<<u<<"__"<<labels[u]<<endl;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	labels.resize(n);
//	cout<<"++++";
	for (int i = 0; i < u.size(); i++) {
		V[u[i]].push_back(v[i]);
		V[v[i]].push_back(u[i]);
	}
	for(int i=0;i<n;i++){
		if(!fix[i]){
			dfs(i,0);
		}
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
//	cout<<"++";
	if(s<c[0]) {
		//inia es
	    if(t>s){	
			for(int i=0;i<c.size()-1;i++){
				if(t<=c[i]) return c[i];
			}
		}
		return c[c.size()-1];			
	}
	else {
		if(t<s){
			for(int i=c.size()-1;i>=1;i--)
			if(t>=c[i]) return c[i];
		}
		return c[0];
	}
}//

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<V[u].size();i++){
      |              ~^~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (int i = 0; i < u.size(); i++) {
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:42:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |    for(int i=0;i<c.size()-1;i++){
      |                ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Invalid labels (duplicates values). scenario=2, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 492 KB Invalid labels (duplicates values). scenario=3, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Invalid labels (duplicates values). scenario=3, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 898 ms 864 KB Output is correct
2 Incorrect 825 ms 896 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Invalid labels (duplicates values). scenario=4, label=0
2 Halted 0 ms 0 KB -