Submission #1318178

#TimeUsernameProblemLanguageResultExecution timeMemory
1318178lucageorgescuEaster Eggs (info1cup17_eastereggs)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; int x=1; void dfs(int nod, int par) { ord.push_back(nod); for (auto v:gr[nod] ) if ( v!=par ) dfs(v,nod); } int findEgg(int n, vector <pair<int,int> > bridges) { for (int i=1; i<=n; i++ ) gr[i].clear(); ord.clear(); for (auto pi:bridges ) { int xixi=pi.first; int y=pi.second; gr[xixi].push_back(y); gr[y].push_back(xixi); } for (int i=1; i<=n; i++ ) if ( gr[i].size()==1 ) { x=i; break; } dfs(x,0); /*for (int i=0; i<ord.size(); i++ ) cout << ord[i] << " ";*/ int st=0, dr=n-1, rez=0; while ( st<=dr ) { int mij=(st+dr)/2; if ( query(vector <int> (ord.begin(),ord.begin()+mij+1))==1 ) { rez=mij; dr=mij-1; } else st=mij+1; } return ord[rez]; }

Compilation message (stderr)

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:10:5: error: 'ord' was not declared in this scope
   10 |     ord.push_back(nod);
      |     ^~~
eastereggs.cpp:12:17: error: 'gr' was not declared in this scope
   12 |     for (auto v:gr[nod] )
      |                 ^~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:20:9: error: 'gr' was not declared in this scope
   20 |         gr[i].clear();
      |         ^~
eastereggs.cpp:21:9: error: 'ord' was not declared in this scope
   21 |         ord.clear();
      |         ^~~
eastereggs.cpp:28:9: error: 'gr' was not declared in this scope
   28 |         gr[xixi].push_back(y);
      |         ^~
eastereggs.cpp:33:14: error: 'gr' was not declared in this scope
   33 |         if ( gr[i].size()==1 ) {
      |              ^~