Submission #918084

# Submission time Handle Problem Language Result Execution time Memory
918084 2024-01-29T13:05:41 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 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(nw))
        {
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    return v[l];
}

Compilation message

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