답안 #497665

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497665 2021-12-23T13:30:24 Z Hanksburger 기지국 (IOI20_stations) C++17
0 / 100
2328 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1005], ans;
int dfs(int U, int P, int cnt, bool X)
{
	if (X)
	{
		ans[U]=cnt;
		cnt++;
		for (int i=0; i<adj[U].size(); i++)
		{
			int V=adj[U][i];
			if (V!=P)
				cnt=dfs(V, U, cnt, 0);
		}
	}
	else
	{
		for (int i=0; i<adj[U].size(); i++)
		{
			int V=adj[U][i];
			if (V!=P)
				cnt=dfs(V, U, cnt, 1);
		}
		ans[U]=cnt;
		cnt++;
	}
	return cnt;
}
vector<int> label(int N, int K, vector<int> U, vector<int> V)
{
	for (int i=0; i<N-1; i++)
	{
		adj[U[i]].push_back(V[i]);
		adj[V[i]].push_back(U[i]);
	}
	for (int i=0; i<N; i++)
		ans.push_back(0);
	dfs(0, -1, 0, 1);
	return ans;
}
int find_next_station(int S, int T, vector<int> C)
{
	if (S<C[0])
	{
		int P=C[C.size()-1];
		if (T<S || T>=P)
			return P;
		for (int i=0; i<C.size(); i++)
			if (T<=C[i])
				return C[i];
	}
	else
	{
		int P=C[0];
		if (T<=P || T>S)
			return P;
		for (int i=C.size()-1; i>=0; i--)
			if (T>=C[i])
				return C[i];
	}
}

Compilation message

stations.cpp: In function 'int dfs(int, int, int, bool)':
stations.cpp:11:18: 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<adj[U].size(); i++)
      |                 ~^~~~~~~~~~~~~~
stations.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for (int i=0; i<adj[U].size(); i++)
      |                 ~^~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:50:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for (int i=0; i<C.size(); i++)
      |                 ~^~~~~~~~~
stations.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1363 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 328 KB Invalid length of array as the response of 'label'. scenario=1, n=994, len=1990
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1235 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB Invalid length of array as the response of 'label'. scenario=1, n=2, len=4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2328 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -