Submission #61623

# Submission time Handle Problem Language Result Execution time Memory
61623 2018-07-26T08:24:07 Z huynhsmd Easter Eggs (info1cup17_eastereggs) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "grader.h"

#define pb push_back
#define fi first
#define se second
using namespace std;

typedef pair <int , int > ii;
const int N = 1e5 + 5;
int arr[N], cnt;
vector < int > adj[N], ask;

void dfs(int u, int p){
	arr[u] = ++cnt;
	for(int v : adj[u]) if(v != p) dfs(v);
}
int findEgg(int N, vector < ii > bridges){
	for(ii i : bridges){
		adj[i.fi].pb(i.se); adj[i.se].pb(i.fi);
	}
	dfs(1, 1);
	int l = 1, r = n, res;
	while(l <= r){
		int mid = l + r >> 1;
		for(int i = 1; i <= mid; ++ i) ask.pb(arr[i]);
		if(query(ask)) res = mid, r = mid - 1;
		else l = mid + 1;
	}
	return arr[res];
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:16:38: error: too few arguments to function 'void dfs(int, int)'
  for(int v : adj[u]) if(v != p) dfs(v);
                                      ^
eastereggs.cpp:14:6: note: declared here
 void dfs(int u, int p){
      ^~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:23:17: error: 'n' was not declared in this scope
  int l = 1, r = n, res;
                 ^
eastereggs.cpp:25:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l + r >> 1;
             ~~^~~
eastereggs.cpp:27:18: error: 'res' was not declared in this scope
   if(query(ask)) res = mid, r = mid - 1;
                  ^~~
eastereggs.cpp:30:13: error: 'res' was not declared in this scope
  return arr[res];
             ^~~