Submission #635771

# Submission time Handle Problem Language Result Execution time Memory
635771 2022-08-26T21:44:37 Z Dec0Dedd Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
248 ms 131072 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

#define pii pair<int, int>

const int N = 513;

vector<int> G[N], pre;
int n;

void dfs(int v, int p) {
   pre.push_back(v);
   for (auto u : G[v]) {
      if (u == p) continue;
      dfs(u, v); 
   }
}

vector<int> genIsl(int m) {
   vector<int> res;
   for (int i=0; i<=m; ++i) res.push_back(pre[i]);
   return res;
}

int findEgg(int sz, vector<pii> x) {
   n=sz;
   for (auto u : x) {
      int a=u.first, b=u.second;
      G[a].push_back(b);
      G[b].push_back(a);
   }
   dfs(1, 1);

   int l=0, r=n-1, res=n-1;
   while (l <= r) {
      int m=(l+r)/2;
      if (query(genIsl(m))) r=m-1, res=m;
      else l=m+1;
   }
   return pre[res];
}
# Verdict Execution time Memory Grader output
1 Runtime error 248 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 212 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 201 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -