답안 #321510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321510 2020-11-12T15:34:24 Z katearima 기지국 (IOI20_stations) C++14
0 / 100
84 ms 1000 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N=1005;
vector<vector<int>> a(N);
vector<int> ans(N);
int i,n,k,m,x,j,t;
void DFS(vector<vector<int>> a, int x,int y,int d){
	if(d%2==0) {ans[y]=t; t++;}
	for(int i=0; i<a[y].size(); i++){
		if(a[y][i]==x) continue;
		DFS(a,y,a[y][i],d+1);
	}
	if(d%2!=0) {ans[y]=t; t++;}
	
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> label(n);
	for(i=0; i<n-1; i++){
		a[u[i]].push_back(v[i]);
		a[v[i]].push_back(u[i]);
	}
    t=0;
	DFS(a,-1,0,0);
	for(i=0; i<n; i++){
		cout<<ans[i]<<endl;
	}
	for(i=0; i<n; i++) label[i]=ans[i];
	ans.clear(); a.clear();
	return label;
}

int find_next_station(int s, int t, vector<int> c) {
	if(s<c[0]){
		c.insert(c.begin(),s);
		for(int i=1; i<c.size()-1; i++){
			if(t<=c[i] && t>=c[i-1]+1) return c[i];//{ans=c[i]; parent=false;}
		}
		return c[c.size()-1];//if(parent) ans=c[c.size()-1];
	}
	else{
		c.push_back(s);
		for(int i=1; i<c.size()-1; i++){
			if(t>=c[i] && t<=c[i+1]-1) return c[i];//{ans=c[i]; parent=false;}
			return c[0];//if(parent) ans=c[0];
		}
		
	}
}

Compilation message

stations.cpp: In function 'void DFS(std::vector<std::vector<int> >, int, int, int)':
stations.cpp:11:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0; i<a[y].size(); i++){
      |               ~^~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:37:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for(int i=1; i<c.size()-1; i++){
      |                ~^~~~~~~~~~~
stations.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for(int i=1; i<c.size()-1; i++){
      |                ~^~~~~~~~~~~
stations.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 84 ms 1000 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 32 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -