Submission #507631

# Submission time Handle Problem Language Result Execution time Memory
507631 2022-01-12T21:07:50 Z Hanksburger Simurgh (IOI17_simurgh) C++17
0 / 100
1 ms 204 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > edge;
bool chosen[25], selected[10];
vector<int> ans;
int NN;
bool recur(int X, int Y)
{
	if (X==NN-1)
	{
		ans.clear();
		for (int i=0; i<edge.size(); i++)
			if (chosen[i])
				ans.push_back(edge[i].second);
		if (count_common_roads(ans)==NN-1)
			return 1;
		else
			return 0;
	}
	for (int i=Y; i<edge.size(); i++)
	{
		if (!chosen[i])
		{
			if (selected[edge[i].first.first] && !selected[edge[i].first.second])
			{
				chosen[i]=1;
				selected[edge[i].first.second]=1;
				if (recur(X+1, i+1))
					return 1;
				chosen[i]=0;
				selected[edge[i].first.second]=0;
			}
			else if (!selected[edge[i].first.first] && selected[edge[i].first.second])
			{
				chosen[i]=1;
				selected[edge[i].first.first]=1;
				if (recur(X+1, i+1))
					return 1;
				chosen[i]=0;
				selected[edge[i].first.first]=0;
			}
		}
	}
	return 0;
}
vector<int> find_roads(int N, vector<int> U, vector<int> V)
{
	if (N<=7)
	{
		NN=N;
		for (int i=0; i<U.size(); i++)
			edge.push_back({{U[i], V[i]}, i});
		sort(edge.begin(), edge.end());
		selected[0]=1;
		recur(0, 0);
		return ans;
	}
}

Compilation message

simurgh.cpp: In function 'bool recur(int, int)':
simurgh.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   for (int i=0; i<edge.size(); i++)
      |                 ~^~~~~~~~~~~~
simurgh.cpp:21:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for (int i=Y; i<edge.size(); i++)
      |                ~^~~~~~~~~~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   for (int i=0; i<U.size(); i++)
      |                 ~^~~~~~~~~
simurgh.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB correct
2 Incorrect 0 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -