Submission #522722

# Submission time Handle Problem Language Result Execution time Memory
522722 2022-02-05T14:52:34 Z Theo830 Easter Eggs (info1cup17_eastereggs) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
vector<vector<ll> >adj;
ll arr[600];
ll tim = 0;
void dfs(ll idx,ll p){
    arr[tim] = idx;
    tim++;
    for(auto x:adj[idx]){
        if(x != p){
            dfs(x,idx);
        }
    }
}
int findEgg(int N, vector < pair < int, int > > bridges){
    adj.assign(N+5,vector<ll>());
    for(auto x:bridges){
        adj[x.F].pb(x.S);
        adj[x.S].pb(x.F);
    }
    dfs(1,0);
    ll l = 0,r = n-1;
    while(l < r){
        ll mid = (l+r)/2;
        vll exo;
        f(i,l,mid){
            exo.pb(arr[i]);
        }
        if(query(exo)){
            r = mid - 1;
        }
        else{
            l = mid;
        }
    }
    return l;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:44:18: error: 'n' was not declared in this scope
   44 |     ll l = 0,r = n-1;
      |                  ^
eastereggs.cpp:51:12: error: 'query' was not declared in this scope
   51 |         if(query(exo)){
      |            ^~~~~