답안 #329628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329628 2020-11-21T20:04:41 Z NintsiChkhaidze 기지국 (IOI20_stations) C++14
0 / 100
4 ms 1252 KB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector <int> vec[1005];
int cnt,in[1005],out[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;
	for (int i=0;i<1000;i++){
		vec[i].clear();
		in[i] = out[i] = 0;
	}
	for (int i=0;i<u.size();i++){
		vec[u[i]].pb(v[i]);
		vec[v[i]].pb(u[i]);
	}
	cnt=0;
	dfs(0,0);
	for (int i=0;i<n;i++)
		labels.pb(in[i]*1001 + 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:9:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  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:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for (int i=0;i<u.size();i++){
      |               ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for (int i=0;i<c.size();i++){
      |                ~^~~~~~~~~
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();i++){
      |                ~^~~~~~~~~
stations.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1011
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 364 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1997
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=4, k=1000000, vertex=476, label=1000999
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1012 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1252 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -