답안 #507614

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
507614 2022-01-12T20:12:55 Z Hanksburger Simurgh (IOI17_simurgh) C++17
0 / 100
8 ms 292 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
bool chosen[25], selected[10];
vector<int> UU, VV, ans;
int NN;
bool recur(int X)
{
	if (X==NN-1)
	{
		ans.clear();
		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=0; i<UU.size(); i++)
	{
		if (!chosen[i])
		{
			if (selected[UU[i]] && !selected[VV[i]])
			{
				chosen[i]=1;
				selected[VV[i]]=1;
				if (recur(X+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))
					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;
		selected[0]=1;
		recur(0);
		return ans;
	}
}

Compilation message

simurgh.cpp: In function 'bool recur(int)':
simurgh.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for (int i=0; i<UU.size(); i++)
      |                 ~^~~~~~~~~~
simurgh.cpp:20:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (int i=0; i<UU.size(); i++)
      |                ~^~~~~~~~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
   57 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 292 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 292 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 292 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB correct
2 Incorrect 5 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 292 KB WA in grader: NO
2 Halted 0 ms 0 KB -