Submission #521976

# Submission time Handle Problem Language Result Execution time Memory
521976 2022-02-03T14:38:19 Z iskhakkutbilim Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
// #include "grader.h"

using namespace std;
vector<int> g[520];
int used[520];
vector<int> island;
queue<int> q;


queue<int> jp;
int findEgg (int N, vector < pair < int, int > > bridges)
{
	// cout << 't';
	memset(used, 0, sizeof(used));
	for(int i = 0;i < N-1; i++){
		int a = bridges[i].first;
		int b = bridges[i].second;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
   	int ans = 1;
   	q.push(1);
   	used[1] = 1;
   	island.push_back(1);
   	jp.push(1);
   	while(!q.empty()){
   		
   		int v = q.front();
   		q.pop();
   		for(auto to : g[v]){
   			if(used[to] == 0){
   				used[to] = 1;
   				q.push(to);
   				island.push_back(to);
   				jp.push(to);
   			}
   			if(jp.size() >= N / 2){
   				
   				if(query(island) == 1){
	   				while(!jp.empty()){
	   					
	   					if(query({jp.front()}) == 1){
	   						return jp.front();
	   					}
	   					jp.pop();
	   				}	
   				}
   				while(!jp.empty()){
	   				jp.pop();
	   			}
	   			// cout << "\n" << "------" << "\n";
   			}		
   		}
   	}
   	while(!jp.empty()){					
		if(query({jp.front()}) == 1){
			return jp.front();
		}
		jp.pop();
	}
	
	for(auto x : island){
		if(query({x})){
			return x;
		}
	}
	island.clear();
   	return 0;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:39:20: warning: comparison of integer expressions of different signedness: 'std::queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |       if(jp.size() >= N / 2){
      |          ~~~~~~~~~~^~~~~~~~
eastereggs.cpp:41:11: error: 'query' was not declared in this scope
   41 |        if(query(island) == 1){
      |           ^~~~~
eastereggs.cpp:58:6: error: 'query' was not declared in this scope
   58 |   if(query({jp.front()}) == 1){
      |      ^~~~~
eastereggs.cpp:65:6: error: 'query' was not declared in this scope
   65 |   if(query({x})){
      |      ^~~~~
eastereggs.cpp:23:9: warning: unused variable 'ans' [-Wunused-variable]
   23 |     int ans = 1;
      |         ^~~