답안 #538827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538827 2022-03-17T20:48:26 Z Spade1 Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
20 ms 464 KB
#include <bits/stdc++.h>
#include "grader.h"
#define pii pair<int, int>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

vector<int> adj[600];
vector<int> ord;

void dfs(int i, int prt) {
    ord.pb(i);
    for (auto j : adj[i]) {
        if (j == prt) continue;
        dfs(j, i);
    }
}

int findEgg(int N, vector<pii> bridges) {
    for (int i = 1; i <= 512; ++i) adj[i].clear();
    ord.clear();
    for (int i = 0; i < N - 1; ++i) {
        int u = bridges[i].st;
        int v = bridges[i].nd;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    dfs(1, 0);
    int l = 0, r = N-1;
    while (l < r) {
        int mid = (l+r)/2;
        vector<int> check;
        for (int i = 0; i <= mid; ++i) check.pb(ord[i]);
        bool q = query(check);
        if (q) r = mid;
        else l = mid + 1;
    }
    return ord[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Number of queries: 4
2 Correct 2 ms 208 KB Number of queries: 4
3 Correct 1 ms 208 KB Number of queries: 4
4 Correct 1 ms 208 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 336 KB Number of queries: 8
2 Correct 11 ms 356 KB Number of queries: 9
3 Correct 20 ms 344 KB Number of queries: 9
4 Correct 14 ms 336 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 364 KB Number of queries: 9
2 Correct 15 ms 360 KB Number of queries: 9
3 Correct 20 ms 464 KB Number of queries: 9
4 Correct 15 ms 352 KB Number of queries: 9