Submission #483648

# Submission time Handle Problem Language Result Execution time Memory
483648 2021-10-31T12:51:09 Z alexdumitru Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> g[550];
int p[550],nrr;
void dfs(int nod=1, int t=0)
{
    p[++nrr]=nod;
    for(auto i:g[nod])if(i!=t)dfs(i,nod);
}
bool qq(int poz)
{
    vector<int> qqq;
    for(int i=1;i<=poz;i++)qqq.push_back(p[i]);
    return query(qqq);
}
int findEgg(int N, vector<pair<int,int> > bridges)
{
    for(int i=1;i<=n;i++)g[i].clear()
    int st=1,dr=N-1,m,poz=N;
    for(auto i:bridges)
    {
        g[i.first].push_back(i.second);
        g[i.second].push_back(i.first);
    }
    dfs();
    while(st<=dr)
    {
        m=st+(dr-st)/2;
        if(qq(m))
        {
            poz=m;
            dr=m-1;
        }
        else st=m+1;
    }
    //cout<<poz<<'\n';
    return p[poz];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:19:20: error: 'n' was not declared in this scope
   19 |     for(int i=1;i<=n;i++)g[i].clear()
      |                    ^
eastereggs.cpp:19:38: error: expected ';' before 'int'
   19 |     for(int i=1;i<=n;i++)g[i].clear()
      |                                      ^
      |                                      ;
   20 |     int st=1,dr=N-1,m,poz=N;
      |     ~~~                               
eastereggs.cpp:27:11: error: 'st' was not declared in this scope; did you mean 'std'?
   27 |     while(st<=dr)
      |           ^~
      |           std
eastereggs.cpp:27:15: error: 'dr' was not declared in this scope
   27 |     while(st<=dr)
      |               ^~
eastereggs.cpp:29:9: error: 'm' was not declared in this scope
   29 |         m=st+(dr-st)/2;
      |         ^
eastereggs.cpp:32:13: error: 'poz' was not declared in this scope; did you mean 'pow'?
   32 |             poz=m;
      |             ^~~
      |             pow
eastereggs.cpp:38:14: error: 'poz' was not declared in this scope; did you mean 'pow'?
   38 |     return p[poz];
      |              ^~~
      |              pow