답안 #922049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
922049 2024-02-04T22:26:16 Z Ianis Easter Eggs (info1cup17_eastereggs) C++17
81 / 100
27 ms 1260 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

using pii = pair<int, int>;

int my_query(const set<int> &s) {
   vector<int> v;
   for (auto &it : s)
      v.push_back(it);
   return query(v);
}

int findEgg(int n, vector<pii> bridges) {
   vector<vector<int>> g(n + 1);
   vector<bool> vis(n + 1);
   vector<int> euler;

   for (auto [ x, y ] : bridges) {
      g[x].push_back(y);
      g[y].push_back(x);
   }

   function<void(int)> dfs = [&](int x) {
      vis[x] = true;
      euler.push_back(x);
      for (auto u : g[x]) {
         if (!vis[u]) {
            dfs(u);
            euler.push_back(x);
         }
      }
   };

   dfs(1);

   function<bool(int)> check = [&](int mid) {
      set<int> s;
      for (int i = 0; i < mid; i++)
         s.insert(euler[i]);
      return !my_query(s);
   };

   int l = 1, r = int(euler.size()) - 1;

   while (l <= r) {
      int mid = (l + r) >> 1;
      if (check(mid)) l = mid + 1;
      else r = mid - 1;
   }

   return euler[r];
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 436 KB Number of queries: 5
2 Partially correct 1 ms 436 KB Number of queries: 5
3 Partially correct 1 ms 344 KB Number of queries: 5
4 Partially correct 1 ms 344 KB Number of queries: 5
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 740 KB Number of queries: 9
2 Partially correct 16 ms 740 KB Number of queries: 10
3 Partially correct 27 ms 1008 KB Number of queries: 10
4 Partially correct 23 ms 1016 KB Number of queries: 10
# 결과 실행 시간 메모리 Grader output
1 Partially correct 26 ms 1112 KB Number of queries: 10
2 Partially correct 21 ms 744 KB Number of queries: 10
3 Partially correct 25 ms 1260 KB Number of queries: 10
4 Partially correct 23 ms 520 KB Number of queries: 10