Submission #918072

# Submission time Handle Problem Language Result Execution time Memory
918072 2024-01-29T13:04:12 Z hugsfromadicto Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb          push_back
#define pii         pair<int, int>
#define pll         pair<ll, ll>
#define vll         vector<ll>
#define all(v)      v.begin(), v.end()
#define whole(a)    a+1, a+1+n
#define OPT         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sec         second
#define fi          first
#define print(k)    cerr << "Ans : "; cout << k << endl;
#define ins         insert
#define int         ll
#define pb          push_back 
#define bpc         __builtin_popcountll
#define skip        continue
#define endll          '\n'
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   a*b / (__gcd(a, b))
#define mpr         make_pair
#define rep(i,l,r)  for(ll i=l;i<=r;++i)
#define new         '\n'
typedef long long ll;
typedef unsigned long long ull;
const int mod = 998244353;
const int sz = 3e5+5;
using namespace std;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
void open(string s, string f)
{
    freopen((s + ".txt").c_str(), "r", stdin);
    freopen((f + ".txt").c_str(), "w", stdout);
}

vector<int>v;
vector<int>g[60];
void dfs(int node, int par)
{
    v.pb(node);
    for(auto i:g[node])
    {
        if(i == par)
        {
            continue;
        }
        dfs(i, node);
    }
}

int findEgg (int n, vector<pair<int, int>> b)
{
    v.clear();
    for(int i = 0; i <= n; ++i)
    {
        g[i].clear();
    }
    for(pii p:b)
    {
        g[p.first].pb(p.second);
        g[p.second].pb(p.first);
    }
    dfs(1,1);
    int l = 0, r = v.size()-1, ans = 0;

    while(l < r)
    {
        int mid = ( l + r ) >> 1;
        vector<int> w;
        for( int i = 0; i <= mid; ++i){
            w.pb(v[i]);
        }
        if(query(w))
        {
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    return v[l];
}

Compilation message

eastereggs.cpp: In function 'll findEgg(ll, std::vector<std::pair<long long int, long long int> >)':
eastereggs.cpp:74:12: error: 'query' was not declared in this scope
   74 |         if(query(w))
      |            ^~~~~
eastereggs.cpp:65:32: warning: unused variable 'ans' [-Wunused-variable]
   65 |     int l = 0, r = v.size()-1, ans = 0;
      |                                ^~~
eastereggs.cpp: In function 'void open(std::string, std::string)':
eastereggs.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen((s + ".txt").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
eastereggs.cpp:34:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     freopen((f + ".txt").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~