Submission #692451

# Submission time Handle Problem Language Result Execution time Memory
692451 2023-02-01T12:56:19 Z MateiKing80 Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
vector<int>v[513];
vector<int>ord;

void dfs (int nod, int tata)
{
    ord.push_back(nod);
    for (int i=0;i<v[nod].size();i++)
    {
        if (v[nod][i] == tata)
            continue;
        dfs(v[nod][i], nod);
    }
}

int findEgg(int n, vector < pair < int, int > > bridges)
{
    for (int i=0;i<n-1;i++)
    {
        v[bridges[i].first].push_back(bridges[i].second);
        v[bridges[i].second].push_back(bridges[i].first);
    }

    dfs(1, 0);

    int l=1, r=n;
    while (l < r)
    {
        int mid = (l + r) / 2;

        vector<int>acm;
        for (int i=0; i<mid; i++)
            acm.push_back(ord[i]);

        if (query(acm))
            r = mid;
        else
            l = mid + 1;
    }

    int ans = ord[r-1];
    for (int i=1; i<=n; i++)
        v[i].clear();
    ord.clear();
    return ret;
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:11:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i=0;i<v[nod].size();i++)
      |                  ~^~~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:48:12: error: 'ret' was not declared in this scope
   48 |     return ret;
      |            ^~~
eastereggs.cpp:44:9: warning: unused variable 'ans' [-Wunused-variable]
   44 |     int ans = ord[r-1];
      |         ^~~