답안 #290568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290568 2020-09-04T03:55:22 Z jairRS Split the Attractions (IOI19_split) C++17
0 / 100
2000 ms 288 KB
#include "split.h"
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adj;
vi degree;
int ga, gb, gc;

void dfs(int src, int prev = -1)
{
	if (gc > 0)
	{
		degree[src] = 3;
		gc--;
	}
	else if (gb > 0)
	{
		degree[src] = 2;
		gb--;
	}
	else if (ga > 0)
	{
		degree[src] = 1;
		ga--;
	}

	for (int a : adj[src])
	{
		if (a != prev)
		{
			dfs(a, src);
			break;
		}
	}
}

vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q)
{
	ga = a;
	gb = b;
	gc = c;
	degree = vi(n, 0);
	adj = vvi(n);
	for (int i = 0; i < p.size(); i++)
	{
		adj[p[i]].push_back(q[i]);
		adj[q[i]].push_back(p[i]);
		degree[p[i]]++;
		degree[q[i]]++;
	}
	bool loop = true;
	for (int i = 0; i < n; i++)
	{
		if (degree[i] == 1)
		{
			dfs(i);
			loop = false;
			break;
		}
	}
	if (loop)
		dfs(0);
	return degree;
}

Compilation message

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for (int i = 0; i < p.size(); i++)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB ok, correct split
2 Execution timed out 2037 ms 288 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB ok, correct split
2 Execution timed out 2044 ms 288 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB invalid split: #1=1, #2=2, #3=2
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2088 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB ok, correct split
2 Execution timed out 2037 ms 288 KB Time limit exceeded
3 Halted 0 ms 0 KB -