답안 #1061551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061551 2024-08-16T10:50:47 Z fv3 Simurgh (IOI17_simurgh) C++14
0 / 100
9 ms 440 KB
#include "simurgh.h"
#include <bits/stdc++.h>

using namespace std;

int N, M;
vector<vector<pair<int, int>>> adj;
vector<int> U, V;

vector<int> res;
void check_tree(vector<int> edges, set<int> nodes)
{
	if (nodes.size() == N)
	{
		int common = count_common_roads(edges);
		if (common == N - 1)
			res = edges;
		return;
	}

	for (auto node : nodes)
	{

		for (auto edge : adj[node])
		{
			if (nodes.count(edge.first))
				continue;

			nodes.insert(edge.first);
			edges.push_back(edge.second);

			check_tree(edges, nodes);

			nodes.erase(edge.first);
			edges.pop_back();
		}
	}
}

vector<int> find_roads(int n, vector<int> u, vector<int> v)
{
	N = n; M = u.size();;
	u = U; v = V;
	adj = vector<vector<pair<int, int>>>(N);

	for (int i = 0; i < M; i++)
	{
		adj[u[i]].push_back({v[i], i});
		adj[v[i]].push_back({u[i], i});
	}

	check_tree({}, {0});

	return res;
}

Compilation message

simurgh.cpp: In function 'void check_tree(std::vector<int>, std::set<int>)':
simurgh.cpp:13:19: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |  if (nodes.size() == N)
      |      ~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB correct
2 Incorrect 5 ms 440 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -