Submission #67731

# Submission time Handle Problem Language Result Execution time Memory
67731 2018-08-15T09:18:23 Z tempytemptemp Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include	<vector>
#include	<cassert>
#include	<algorithm>
#include	"grader.h"
using namespace std;

int findEgg(int N, vector < pair < int, int > > bridges);
int query(vector < int > islands);

int findEgg(int n, vector<pair<int,int>>bridges){
	assert(n<=16);
	bool pos[n+1];
	for(int i=1; i<=n; i++)	pos[i]=1;
	for(int i=0; i<bridges.size(); i++){
		if(!pos[bridges[i].first] && !pos[bridges[i].second])
			continue;
		if(!pos[bridges[i].first]){
			if(query({bridges[i].second}))
				return bridges[i].second;
			else{
				pos[bridges[i].second]=0;
				continue;
			}
		}
		else if(!pos[bridges[i].second){
			if(query({bridges[i].first}))
				return bridges[i].first;
			else{
				pos[bridges[i].first]=0;
				continue;
			}
		}
		if(query({bridges[i].first, bridges[i].second})){
			if(query({bridges[i].first}))
				return bridges[i].first;
			else
				return bridges[i].second;
		}
		else{
			pos[bridges[i].first]=pos[bridges[i].second]=0;
		}
	}
	return -1;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:14:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<bridges.size(); i++){
               ~^~~~~~~~~~~~~~~
eastereggs.cpp:25:33: error: expected ']' before ')' token
   else if(!pos[bridges[i].second){
                                 ^