답안 #329611

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329611 2020-11-21T19:27:38 Z NintsiChkhaidze 기지국 (IOI20_stations) C++14
0 / 100
1 ms 492 KB
#include "stations.h"
#include <bits/stdc++.h>
#include <vector>
#define pb push_back
#define N 1001
using namespace std;
int cnt,in[1005],out[1005];
vector <int> vec[1005];
void dfs(int x,int p){
	in[x] = ++cnt;
	for (int j=0;j<vec[x].size();j++){
		int to = vec[x][j];
		if (to == p) continue;
		dfs(to,x);
	}
	out[x] = cnt++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(n);
	
	for (int i=0;i<u.size();i++){
		vec[u[i]].pb(v[i]);
		vec[v[i]].pb(u[i]);
	}
	dfs(0,0);
	for (int i=0;i<n;i++)
		labels.pb(in[i]*N + out[i]);
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	if (in[s] < in[t]){
		for (int i=0;i<c.size();i++){
			int x = c[i];
			if (in[t] > in[x] && out[x] > out[t]) return x; 
		}
	}
	else{
		for (int i=0;i<c.size();i++){
			int x = c[i];
			if (in[t] < in[x] && out[x] < out[t]) return x; 
		}
	}
}

Compilation message

stations.cpp: In function 'void dfs(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 j=0;j<vec[x].size();j++){
      |               ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:21:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for (int i=0;i<u.size();i++){
      |               ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for (int i=0;i<c.size();i++){
      |                ~^~~~~~~~~
stations.cpp:39:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for (int i=0;i<c.size();i++){
      |                ~^~~~~~~~~
stations.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Invalid length of array as the response of 'label'. scenario=0, n=10, len=20
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Invalid length of array as the response of 'label'. scenario=0, n=996, len=1992
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 396 KB Invalid length of array as the response of 'label'. scenario=0, n=2, len=4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 492 KB Invalid length of array as the response of 'label'. scenario=0, n=2, len=4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Invalid length of array as the response of 'label'. scenario=0, n=3, len=6
2 Halted 0 ms 0 KB -