Submission #484545

# Submission time Handle Problem Language Result Execution time Memory
484545 2021-11-04T11:24:36 Z MohamedFaresNebili Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")

        using namespace std;

        using ll  = long long;
        using vi  = vector<int>;

        #define pb push_back
        #define ff first
        #define ss second
        #define lb lower_bound
        #define all(x) (x).begin() , (x).end()

        #include "grader.h"

        /// int query (vector < int > h); vector<int> id;
        vector<int>adj[555]; int timer, tin[555], out[555];
        void dfs(int v, int p) {
            tin[v] = timer++; id.pb(v);
            for(auto u: adj[v]) {
                if(u == p) continue;
                dfs(u, v);
            }
            out[v] = timer - 1;
        }


        int findEgg (int N, vector < pair < int, int > > bridges)
        {
            for(auto u : bridges) {
                int a = u.ff, b = u.ss;
                adj[a].pb(b); adj[b].pb(a);
            }
            timer = 0; dfs(1, 1);
            int lo = 0, hi = N - 1;
            for(;lo != hi;) {
                vector<int>arr;
                for(int l = lo; l <= hi; l++) arr.pb(id[l]);
                bool ok = query(arr);
                if(ok) hi = out[id[lo]];
                else lo = tin[id[lo]] + 1;
            }
            return lo;
        }

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:21:31: error: 'id' was not declared in this scope
   21 |             tin[v] = timer++; id.pb(v);
      |                               ^~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:40:54: error: 'id' was not declared in this scope
   40 |                 for(int l = lo; l <= hi; l++) arr.pb(id[l]);
      |                                                      ^~
eastereggs.cpp:42:33: error: 'id' was not declared in this scope
   42 |                 if(ok) hi = out[id[lo]];
      |                                 ^~
eastereggs.cpp:43:31: error: 'id' was not declared in this scope
   43 |                 else lo = tin[id[lo]] + 1;
      |                               ^~