Submission #423023

# Submission time Handle Problem Language Result Execution time Memory
423023 2021-06-10T16:03:34 Z albertolg101 Simurgh (IOI17_simurgh) C++17
0 / 100
6 ms 332 KB
#include <bits/stdc++.h>
#include "simurgh.h"

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

void print (vector<int> &ar)
{
	for(auto i: ar)
		cout << i << ' ' ; 
	cout << endl ;
}

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

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

	int nextNod;
	vector<int> perm;

	for(int i = 0 ; i < n ; i++)
		perm.push_back(i);

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

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

	do
	{
		nextNod = 0;
		vector<int> vans;
		dfs(perm[0], vans);
		if(vans.size() == n - 1 and count_common_roads(vans) == n - 1)
			return vans;

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

	assert(false);
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i = 0 ; i < u.size() ; i++)
      |                  ~~^~~~~~~~~~
simurgh.cpp: In lambda function:
simurgh.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   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:46:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |   if(vans.size() == n - 1 and count_common_roads(vans) == n - 1)
      |      ~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB correct
2 Incorrect 6 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -