Submission #649490

# Submission time Handle Problem Language Result Execution time Memory
649490 2022-10-10T09:54:08 Z yelul Easter Eggs (info1cup17_eastereggs) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> o;

void order(int x, int t, vector<vector<int>> v) {
  o.push_back(x);
  for (int i : v[x]) {
    if (i == t)
      continue;
    order(i, x, v);
  }
}

int findEgg(int N, vector < pair < int, int > > bridges) {

  vector<vector<int>> g(N+1);
  
  for (auto p : bridges) {
    int u = p.first, v = p.second;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  
  order(1, -1, g);

  int l = 0, r = N-2, mid, x = N-1;
  while (l <= r) {
    mid = (l+r)/2;
    vector<int> a;
    for (int i=0; i<=mid; i++)
      a.push_back(o[i]);
    if (query(a)) {
      r = mid-1;
      x = mid;
    } else {
      l = mid+1;
    }
  }

  int ans = o[x];
  o.clear();

  return ans;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:33:9: error: 'query' was not declared in this scope
   33 |     if (query(a)) {
      |         ^~~~~