Submission #1128271

#TimeUsernameProblemLanguageResultExecution timeMemory
1128271enzyEaster Eggs (info1cup17_eastereggs)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; const int maxn=514; vector<int>v[maxn]; int pre[maxn], lin[maxn], tmp; void dfs(int u){ tmp++; pre[u]=tmp; for(auto viz : v[u]){ if(pre[viz]) continue; dfs(viz); } } bool check(int x){ vector<int>ask; for(int i=1;i<=x;i++) ask.push_back(lin[i]); return query(ask); } int findEgg (int N,vector<pair<int,int>> bridges){ for(auto p : bridges){ v[p.first].push_back(p.second); v[p.second].push_back(p.first); } dfs(1); for(int i=1;i<=n;i++) lin[pre[i]]=i; int l=1, r=n; while(l<r){ int mid=(l+r)/2; if(check(mid)) r=mid; else l=mid+1; } return lin[l]; }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:27:20: error: 'n' was not declared in this scope
   27 |     for(int i=1;i<=n;i++) lin[pre[i]]=i;
      |                    ^
eastereggs.cpp:28:16: error: 'n' was not declared in this scope
   28 |     int l=1, r=n;
      |                ^