답안 #1029637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029637 2024-07-21T06:51:22 Z coolboy19521 Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

const int sz = 600;

vector<int> aj[sz];
vector<int> pt;

void dfs(int v, int p = -1) {
    pt.push_back(v);
    for (int u : aj[v]) if (u != p)
        dfs(u, v);
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    for (int i = 1; i <= N; i ++)
        aj[i].clear();

    pt.clear();

    for (auto& [v, u] : bridges) {
        aj[v].push_back(u);
        aj[u].push_back(v);
    }

    dfs(1);

    int le = 0, ri = N;
    int r;

    while (1 < ri - le) {
        int mi = le + (ri - le) / 2;
        vector<int> q;
        for (int i = 1; i <= mi; i ++)
            q.push_back(pt[i - 1]);
        r = query(q);
        if (r) ri = mi;
        else le = mi;
    }

    if (!r)
        return pt[N - 1];

    return pt[ri - 1];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:44:5: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |     if (!r)
      |     ^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -