Submission #1341294

#TimeUsernameProblemLanguageResultExecution timeMemory
1341294ayazEaster Eggs (info1cup17_eastereggs)C++20
32 / 100
1 ms476 KiB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

const int sz = 600;

vector<int> g[sz];
int tin[sz], timer = 0;
void dfs(int u, int p) {
  tin[++timer] = u;
  for (auto &v : g[u]) {
    if (v != p) {
      dfs(v, u);
    }
  }
}
int findEgg (int N, vector<pair<int, int>> bridges)
{
  for (int i = 1; i <= N; i++) {
    g[i].clear();
  }
  for (auto [x, y] : bridges) {
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, -1);
  int low = 1, high = N, best = -1;
  while (low <= high) {
    int mid = (low + high) >> 1;
    vector<int> nodes;
    for (int i = 1; i <= mid; i++) nodes.push_back(tin[i]);
    if (query(nodes) == 1) {
      high = mid - 1;
      best = mid;
    } else {
      low = mid + 1;
    }
  }
  assert(best != -1);
  return tin[best];
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...