Submission #918896

# Submission time Handle Problem Language Result Execution time Memory
918896 2024-01-30T17:29:34 Z Moonn Easter Eggs (info1cup17_eastereggs) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define inti long long
#define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespac
vector<vector<int>>v;
vector<bool>ch;
vector<int>g;
void dfs(int n,int x)
{
    ch[x]=1;
    for(int i:v[x])
    {
        if(!ch[i])
        dfs(n,i);
    }
    g.push_back(x);
}
int findEgg(int n, vector < pair < int, int > > bridges)
{
    v.resize(n+1);
    ch.resize(n+1,0);
    for(int i=0;i<bridges.size();i++)
    {
        int a=bridges[i].first;
        int b=bridges[i].second;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(n,1);
    int l,r,mid;
    l=0;
    r=g.size()-1;
    vector<int>vi;
    while(l<r)
    {
        vi.clear();
        mid=(l+r)/2;
        for(int i=0;i<=mid;i++)
        vi.push_back(g[i]);
        if(query(vi))
        r=mid;
        else
        l=mid+1;
    }
    return g[l];
}
int main()
{

}

Compilation message

eastereggs.cpp:4:7: error: expected nested-name-specifier before 'namespac'
    4 | using namespac
      |       ^~~~~~~~
eastereggs.cpp:6:1: error: 'vector' does not name a type
    6 | vector<bool>ch;
      | ^~~~~~
eastereggs.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int>g;
      | ^~~~~~
eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:10:5: error: 'ch' was not declared in this scope
   10 |     ch[x]=1;
      |     ^~
eastereggs.cpp:11:15: error: 'v' was not declared in this scope
   11 |     for(int i:v[x])
      |               ^
eastereggs.cpp:16:5: error: 'g' was not declared in this scope
   16 |     g.push_back(x);
      |     ^
eastereggs.cpp: At global scope:
eastereggs.cpp:18:20: error: 'vector' has not been declared
   18 | int findEgg(int n, vector < pair < int, int > > bridges)
      |                    ^~~~~~
eastereggs.cpp:18:27: error: expected ',' or '...' before '<' token
   18 | int findEgg(int n, vector < pair < int, int > > bridges)
      |                           ^
eastereggs.cpp: In function 'int findEgg(int, int)':
eastereggs.cpp:20:5: error: 'v' was not declared in this scope
   20 |     v.resize(n+1);
      |     ^
eastereggs.cpp:21:5: error: 'ch' was not declared in this scope
   21 |     ch.resize(n+1,0);
      |     ^~
eastereggs.cpp:22:19: error: 'bridges' was not declared in this scope
   22 |     for(int i=0;i<bridges.size();i++)
      |                   ^~~~~~~
eastereggs.cpp:32:7: error: 'g' was not declared in this scope
   32 |     r=g.size()-1;
      |       ^
eastereggs.cpp:33:5: error: 'vector' was not declared in this scope
   33 |     vector<int>vi;
      |     ^~~~~~
eastereggs.cpp:33:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from eastereggs.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from eastereggs.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
eastereggs.cpp:33:12: error: expected primary-expression before 'int'
   33 |     vector<int>vi;
      |            ^~~
eastereggs.cpp:36:9: error: 'vi' was not declared in this scope
   36 |         vi.clear();
      |         ^~
eastereggs.cpp:40:12: error: 'query' was not declared in this scope
   40 |         if(query(vi))
      |            ^~~~~