Submission #744340

# Submission time Handle Problem Language Result Execution time Memory
744340 2023-05-18T12:46:16 Z MON Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <vector>
#include<cassert>
#include<iostream>
#include "grader.h"
using namespace std;

vector<int> e,vecini[513];

void dfs(int a = 1,int p = -1)
{
    e.emplace_back(a);
    for(auto &it : vecini[a])
        if(it != p) dfs(it,a);
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    for(int i = 1; i <= N ; i++) vecini[i].clear();
    e.clear();
    for(auto &it : bridges)
        {
            vecini[it.first].emplace_back(it.second);
            vecini[it.second].emplace_back(it.first);
        }

    dfs(1,-1);
    assert(e.size() == N);
    int st = 0,dr = n - 1,ans = -1;
    while(st <= dr)
        {
            int mid = st + (dr - st) / 2;
            if(query(vector<int>(e.begin(),e.begin() + mid)))
                {
                    ans = mid;
                    dr = mid - 1;
                }

            else st = mid + 1;
        }

    return e[ans];
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from grader.h:1,
                 from eastereggs.cpp:4:
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:27:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     assert(e.size() == N);
      |            ~~~~~~~~~^~~~
eastereggs.cpp:28:21: error: 'n' was not declared in this scope
   28 |     int st = 0,dr = n - 1,ans = -1;
      |                     ^
eastereggs.cpp:34:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |                     ans = mid;
      |                     ^~~
      |                     abs
eastereggs.cpp:41:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |     return e[ans];
      |              ^~~
      |              abs