Submission #1189872

#TimeUsernameProblemLanguageResultExecution timeMemory
1189872racha555Easter Eggs (info1cup17_eastereggs)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

void dfs(int u){
    for(auto v:adj[u]){
        if(path[v].empty()){
            path[v]=path[u];
       
            path[v].emplace_back(v);
            dfs(v);
        }
    }
}
int  findEgg (int N, vector < pair < int, int > > bridges)
{
    vector<int> adj[513],path[513];
    for(auto [u,v]:bridges){
          adj[u].emplace_back(v);
          adj[v].emplace_back(u);
    }
    path[1].emplace_back(1);
    dfs(1);
 
    path[1].emplace_back(1);
    int l=0,mid,r=N;
    while(l<r){
        int  mid=l+(r-l)/2;
        if(query(path[mid])==1){
            r=mid;
        }
        else{
            l=mid+1;
        }
    }
    return r;
    // if (query ({1})) return 1;
    // return N;

}
// int main(){
//     findEgg(5,{{1,2},{1,3},{2,4},{4,5}});
// }

Compilation message (stderr)

eastereggs.cpp: In function 'void dfs(int)':
eastereggs.cpp:7:16: error: 'adj' was not declared in this scope
    7 |     for(auto v:adj[u]){
      |                ^~~
eastereggs.cpp:8:12: error: 'path' was not declared in this scope; did you mean 'std::filesystem::__cxx11::path'?
    8 |         if(path[v].empty()){
      |            ^~~~
      |            std::filesystem::__cxx11::path
In file included from /usr/include/c++/11/filesystem:45,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from eastereggs.cpp:1:
/usr/include/c++/11/bits/fs_path.h:248:9: note: 'std::filesystem::__cxx11::path' declared here
  248 |   class path
      |         ^~~~