답안 #901496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
901496 2024-01-09T13:24:02 Z ivaziva Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

long long n;
vector<long long> adj[MAXN];
vector<long long> nodes;
vector<int> vec;

void dfs(long long node,long long pret)
{
    nodes.push_back(node);
    long long s=adj[node].size();
    for (long long i=0;i<s;i++)
    {
        long long sled=adj[node][i];
        if (sled!=pret) dfs(sled,node);
    }
}

bool check(long long mid)
{
    for (long i=0;i<=mid;i++) vec.push_back(nodes[i]);
    long long ans=query(vec);vec.clear();
    if (ans==1) return true;
    return false;
}

int findEgg(int N, vector < pair < int, int > > bridges)
{
    n=N;nodes.clear();
    for (long long i=0;i<MAXN;i++) adj[i].clear();
    for (long long i=0;i<n-1;i++)
    {
        long long x=bridges[i].first;
        long long y=bridges[i].second;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1,0);
    long long l=0;
    long long r=n-1;
    long long rez=-1;
    while (l<=r)
    {
        long long mid=(l+r)/2;
        if (check(mid)) {rez=mid;r=mid-1;}
        else l=mid+1;
    }
    return nodes[rez];
};

Compilation message

eastereggs.cpp:5:23: error: 'MAXN' was not declared in this scope
    5 | vector<long long> adj[MAXN];
      |                       ^~~~
eastereggs.cpp: In function 'void dfs(long long int, long long int)':
eastereggs.cpp:12:17: error: 'adj' was not declared in this scope
   12 |     long long s=adj[node].size();
      |                 ^~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:31:26: error: 'MAXN' was not declared in this scope
   31 |     for (long long i=0;i<MAXN;i++) adj[i].clear();
      |                          ^~~~
eastereggs.cpp:31:36: error: 'adj' was not declared in this scope
   31 |     for (long long i=0;i<MAXN;i++) adj[i].clear();
      |                                    ^~~
eastereggs.cpp:36:9: error: 'adj' was not declared in this scope
   36 |         adj[x].push_back(y);
      |         ^~~