답안 #422996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
422996 2021-06-10T15:24:30 Z albertolg101 Simurgh (IOI17_simurgh) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#include "simurgh.h"

using namespace std;
using pii = pair<int, int>;

std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
	
	vector<vector<int>> g(n, vector<int> (n));

	for(int i = 0 ; i < n ; i++)
	{
		int a = u[i], b = v[i];
		g[a][b] = g[b][a] = i;
	}

	int nextNod = 0;
	vector<int> vans, perm(n);

	for(int i = 0 ; i < n ; i++)
		perm[i] = i;

	function<void(int)> dfs = [&](int nod)
	{
		nextNod++;

		while(nextNod < perm.size() and g[nod][perm[nextNod]] != -1)
		{
			vans.push_back(g[nod][perm[nextNod]]);
			dfs(perm[nextNod]);
		}
	};

	do
	{
		vans.clear();
		nextNod = 0;
		dfs(perm[0]);
		if(vans.size() == n - 1 and count_common_roads(vans) == n - 1)
			return vans;

	} while(next_permutation(perm.begin(), perm.end()));
}

Compilation message

simurgh.cpp: In lambda function:
simurgh.cpp:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   while(nextNod < perm.size() and g[nod][perm[nextNod]] != -1)
      |         ~~~~~~~~^~~~~~~~~~~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:39:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |   if(vans.size() == n - 1 and count_common_roads(vans) == n - 1)
      |      ~~~~~~~~~~~~^~~~~~~~
simurgh.cpp:9:42: warning: control reaches end of non-void function [-Wreturn-type]
    9 |  vector<vector<int>> g(n, vector<int> (n));
      |                                          ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB correct
2 Incorrect 1 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -