답안 #951892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951892 2024-03-22T22:03:10 Z __Davit__ Easter Eggs (info1cup17_eastereggs) C++17
87 / 100
12 ms 1248 KB
#include "grader.h"
#include <bits/stdc++.h>

using namespace std;
namespace {
    vector<int> order;
    vector<vector<int>> gp;

    void dfs(int u, int p = -1) {
        order.push_back(u);
        for (auto x: gp[u]) {
            if (x == p)continue;
            dfs(x, u);
        }
    }
}

int findEgg(int N, vector<pair<int, int>> bridges) {
    gp.clear();
    gp.resize(N + 1);
    order.clear();
    for (pair<int, int> i: bridges) {
        gp[i.first].push_back(i.second);
        gp[i.second].push_back(i.first);
    }
    dfs(1);
    int ina = 1, inb = N, ans = order.back();
    while (ina <= inb) {
        int mid = (ina + inb) >> 1;
        vector<int> tmp;
        for (int i = 0; i < mid; i++) tmp.push_back(order[i]);
        bool ok = query(tmp);
        if (ok) {
            inb = mid - 1;
            ans = tmp.back();
        } else ina = mid + 1;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 344 KB Number of queries: 5
2 Partially correct 1 ms 344 KB Number of queries: 5
3 Partially correct 0 ms 344 KB Number of queries: 5
4 Partially correct 1 ms 344 KB Number of queries: 5
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 728 KB Number of queries: 9
2 Correct 8 ms 740 KB Number of queries: 9
3 Correct 12 ms 732 KB Number of queries: 9
4 Correct 10 ms 1248 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Partially correct 12 ms 516 KB Number of queries: 10
2 Correct 10 ms 500 KB Number of queries: 9
3 Partially correct 11 ms 992 KB Number of queries: 10
4 Partially correct 11 ms 744 KB Number of queries: 10