답안 #287198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
287198 2020-08-31T13:28:27 Z andreiomd Easter Eggs (info1cup17_eastereggs) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

typedef pair < int, int > PII;

const int NMAX = 515;
const int ROOT = 1;

const int INF = 1e9;

int N, ans;
vector < int > G[NMAX];

int W[NMAX], Size;

int centroid;
bool used[NMAX];

static inline bool Ask (vector < int > Set)
{
    return query(Set);
}

static inline void Add_Edge (int X, int Y)
{
    G[X].push_back(Y), G[Y].push_back(X);

    return;
}

static inline void DFS (int Node, int Father)
{
    W[Node] = 1;

    for(auto it : G[Node])
        if(!used[it] && it != Father)
        {
            DFS(it, Node);

            W[Node] += W[it];
        }

    return;
}

static inline PII Find (int Node, int Father)
{
    int Max = (Size - W[Node]);
    PII ans = {0, INF};

    for(auto it : G[Node])
        if(!used[it] && it != Father)
        {
            PII curr = Find(it, Node);

            if(curr.second < ans.second)
                ans = curr;
        }

    if(Max < ans.second)
        ans = {Node, Max};

    return ans;
}

static inline void Scan (int Node, int Father, vector < int > &Container)
{
    Container.push_back(Node);

    for(auto it : G[Node])
        if(!used[it] && it != Father)
            Scan(it, Node, Container);

    return;
}

static inline void Go (int Node)
{
    if(ans)
        return;

    DFS(Node, 0);
    Size = W[Node];

    PII Now = Find(Node, 0);
    centroid = Now.first;

    used[centroid] = 1;

    vector < int > V;
    V.push_back(centroid);

    if(Ask(V))
    {
        ans = centroid;

        return;
    }

    for(auto it : G[centroid])
        if(!used[it])
        {
            V.clear();

            Scan(it, centroid, V);

            if(Ask(V))
            {
                Go(it);

                return;
            }
        }

    return;
}

inline int findEgg (int n, vector < PII > bridges)
{
    N = n;

    for(auto it : bridges)
    {
        int X = it.first, Y = it.second;

        Add_Edge(X, Y);
    }

    Go(ROOT);

    return ans;
}

Compilation message

/tmp/ccOtaewk.o: In function `main':
grader.cpp:(.text.startup+0x1d1): undefined reference to `findEgg(int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >)'
collect2: error: ld returned 1 exit status