답안 #507622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
507622 2022-01-12T20:54:48 Z Hanksburger Simurgh (IOI17_simurgh) C++17
0 / 100
6 ms 288 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
bool chosen[25], selected[10];
vector<int> UU, VV, ans;
int NN, cnt;
bool recur(int X, int Y)
{
	if (X==NN-1)
	{
		ans.clear();
		cnt++;
		for (int i=0; i<UU.size(); i++)
			if (chosen[i])
				ans.push_back(i);
		if (count_common_roads(ans)==NN-1)
			return 1;
		else
			return 0;
	}
	for (int i=Y; i<UU.size(); i++)
	{
		if (!chosen[i])
		{
			if (X==0)
			{
				chosen[i]=1;
				selected[UU[i]]=1;
				selected[VV[i]]=1;
				if (recur(X+1, i+1))
					return 1;
				chosen[i]=0;
				selected[UU[i]]=0;
				selected[VV[i]]=0;
				continue;
			}
			if (selected[UU[i]] && !selected[VV[i]])
			{
				chosen[i]=1;
				selected[VV[i]]=1;
				if (recur(X+1, i+1))
					return 1;
				chosen[i]=0;
				selected[VV[i]]=0;
			}
			else if (!selected[UU[i]] && selected[VV[i]])
			{
				chosen[i]=1;
				selected[UU[i]]=1;
				if (recur(X+1, i+1))
					return 1;
				chosen[i]=0;
				selected[UU[i]]=0;
			}
		}
	}
	return 0;
}
vector<int> find_roads(int N, vector<int> U, vector<int> V)
{
	if (N<=7)
	{
		NN=N;
		UU=U;
		VV=V;
		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<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   for (int i=0; i<UU.size(); i++)
      |                 ~^~~~~~~~~~
simurgh.cpp:21:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for (int i=Y; i<UU.size(); i++)
      |                ~^~~~~~~~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:69:1: warning: control reaches end of non-void function [-Wreturn-type]
   69 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB correct
2 Incorrect 1 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB correct
2 Incorrect 1 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB correct
2 Incorrect 1 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 268 KB correct
2 Incorrect 6 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB correct
2 Incorrect 1 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -