Submission #153521

# Submission time Handle Problem Language Result Execution time Memory
153521 2019-09-14T12:25:28 Z nicolaalexandra Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
#define DIM 530
using namespace std;
vector <int> E,v,L[DIM];
int n,i,x,y;
vector <pair<int,int> > mch;
/*int query (vector <int> v){
    for (int i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    cout<<endl;
    int ans;
    cin>>ans;
    return ans;
}*/

void dfs (int nod, int tata){
    E.push_back(nod);
    for (int i=0;i<L[nod].size();i++){
        int vecin = L[nod][i];
        if (vecin != tata)
            dfs (vecin,nod);
    }
    E.push_back(nod);
}
int verif (int poz1, int poz2){
    v.clear();
    for (int i=poz1;i<=poz2;i++)
        v.push_back(E[i]);
    sort (v.begin(),v.end());
    v.resize(unique(v.begin(),v.end())-v.begin());
    return query (v);
}
int findEgg (int n, vector <pair<int,int> > mch){
    for (int i=1;i<=n;i++)
        L[i].clear();
    for (int i=0;i<n-1;i++){
        int x = mch[i].first, y = mch[i].second;
        L[x].push_back(y);
        L[y].push_back(x);
    }
    E.clear();
    dfs (1,0);
    int st = 0, dr = E.size()-1;
    while (st < dr){
        int mid = (st+dr)>>1;
        if (verif (st,mid))
            dr = mid;
        else{
            if (verif (mid+1,dr))
                st = mid+1;
        }}
    return E[st];
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:20:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<L[nod].size();i++){
                  ~^~~~~~~~~~~~~~
eastereggs.cpp: In function 'int verif(int, int)':
eastereggs.cpp:33:12: error: 'query' was not declared in this scope
     return query (v);
            ^~~~~