Submission #381697

# Submission time Handle Problem Language Result Execution time Memory
381697 2021-03-25T17:26:53 Z wind_reaper Easter Eggs (info1cup17_eastereggs) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
	
const int MXN = 512;
vector<int> adj[MXN], ord;

void dfs(int node = 0, int par = -1){
	ord.push_back(node+1);
	for(int v : adj[node]){
		if(v == par)
			continue;
		dfs(v, node);
	}
}

findEgg(int N, vector<pair<int, int>> edges){
	for(auto& [u, v] : edges){
		--u, --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dfs();

	int lo = 0, hi = n-1;
	while(lo < hi){
		int mid = (lo + hi + 1) >> 1;
		if(query(vector<int>(ord.begin(), ord.begin() + mid)))
			hi = mid - 1;
		else lo = mid;
	}

	return ord[lo];
}

Compilation message

eastereggs.cpp:17:44: error: ISO C++ forbids declaration of 'findEgg' with no type [-fpermissive]
   17 | findEgg(int N, vector<pair<int, int>> edges){
      |                                            ^
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:26:19: error: 'n' was not declared in this scope
   26 |  int lo = 0, hi = n-1;
      |                   ^
eastereggs.cpp:29:6: error: 'query' was not declared in this scope
   29 |   if(query(vector<int>(ord.begin(), ord.begin() + mid)))
      |      ^~~~~