답안 #1097033

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097033 2024-10-05T21:06:46 Z bvv23 Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
const int N = 600;
vector <int> g[N];
vector <int> path;

void dfs(int node, int p = - 1) {
    path.push_back(node);
    for (auto v : g[node]) {
        if (v != p) {
            dfs(v, node);
        }
    }
}
int findEgg (int N, vector <pair<int, int >> edges)
{
    path.clear();
    for (int i = 0; i <= n; i++) {
        g[i].clear();
    }
    for (auto v : edges) {
        g[v.first].push_back(v.second);
        g[v.second].push_back(v.first);
    }
    dfs(1);
    int l = 0, r = n - 1;
    // if this current path is ok, then look for more min answer
    int ans = 0;
    while (l <= r) {
        int mid = (l + r) >> 1;
        lst.clear();
        for (int i = 0; i <= mid; i++) {
            lst.push_back(path[i]);
        }
        if (query(lst)) {
            r = mid - 1;
            ans = query[mid];
        }
        else {
            l = mid + 1;
        }
    }
    return ans;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:20:26: error: 'n' was not declared in this scope
   20 |     for (int i = 0; i <= n; i++) {
      |                          ^
eastereggs.cpp:28:20: error: 'n' was not declared in this scope
   28 |     int l = 0, r = n - 1;
      |                    ^
eastereggs.cpp:33:9: error: 'lst' was not declared in this scope
   33 |         lst.clear();
      |         ^~~
eastereggs.cpp:39:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   39 |             ans = query[mid];
      |                            ^
eastereggs.cpp:39:28: error: invalid conversion from 'int (*)(std::vector<int>)' to 'int' [-fpermissive]
   39 |             ans = query[mid];
      |                   ~~~~~~~~~^
      |                            |
      |                            int (*)(std::vector<int>)