Submission #692339

# Submission time Handle Problem Language Result Execution time Memory
692339 2023-02-01T11:01:13 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>ord;
vector<int> v[600];
void dfs(int nod, int tata)
{
    ord.push_back(nod);
    for(int i=0;i<v[nod].size();i++)
    {
        if(v[nod][i]!=tata)
            dfs(v[nod][i],nod);
    }
}

bool sus(int st, int dr)
{
    vector<int>vct;
    for(int i=st;i<=dr;i++)
        vct.push_back(ord[i]);
    return query(vct);
}



int findEgg(int n, vector<pair<int, int> > > bridge)
{
    for(int i=0;i<n-1;i++)
    {
        v[bridge[i].first].push_back(bridge[i].second);
        v[bridge[i].second].push_back(bridge[i].first);
    }
    dfs(1,0);
    int poz=0, int pas=(1<<(int)log2(n));
    while(pas>0)
    {
        if(!sus(poz,poz+pas))
            poz=poz+pas+1;
        pas/=2;
    }
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<v[nod].size();i++)
      |                 ~^~~~~~~~~~~~~~
eastereggs.cpp: At global scope:
eastereggs.cpp:27:44: error: expected ',' or '...' before '>' token
   27 | int findEgg(int n, vector<pair<int, int> > > bridge)
      |                                            ^
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:31:11: error: 'bridge' was not declared in this scope
   31 |         v[bridge[i].first].push_back(bridge[i].second);
      |           ^~~~~~
eastereggs.cpp:35:16: error: expected unqualified-id before 'int'
   35 |     int poz=0, int pas=(1<<(int)log2(n));
      |                ^~~
eastereggs.cpp:36:11: error: 'pas' was not declared in this scope
   36 |     while(pas>0)
      |           ^~~
eastereggs.cpp:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^