답안 #951870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951870 2024-03-22T21:19:52 Z __Davit__ Easter Eggs (info1cup17_eastereggs) C++17
32 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#include "grader.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) {
    order.clear();
    gp.clear();
    gp.resize(N + 1);
    for (int i = 0; i < N; i++) {
        gp[bridges[i].first].push_back(bridges[i].second);
        swap(bridges[i].first, bridges[i].second);
        gp[bridges[i].first].push_back(bridges[i].second);
    }
    dfs(1);
    int ina = 1, inb = N, ans = N;
    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) {
            ans = mid;
            inb = mid - 1;
        } else {
            ina = mid + 1;
        }
    }

    return order[ans-1];
}
# 결과 실행 시간 메모리 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 1 ms 344 KB Number of queries: 5
4 Partially correct 1 ms 344 KB Number of queries: 5
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -