Submission #1226495

#TimeUsernameProblemLanguageResultExecution timeMemory
1226495kokoxuyaEaster Eggs (info1cup17_eastereggs)C++20
0 / 100
0 ms484 KiB
#include "grader.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define pii pair<int,int> #define ss second #define ff first #define piii pair<int,pii> #define debu(x) (cerr << #x << " = "<< x << "\n") #define debu2(x,y) (cerr << #x << " = "<< x << " " << #y << " = " << y << "\n") #define debu3(x,y,z) (cerr << #x << " = "<< x << " " << #y << " = " << y << " " << #z << " = " << z<< "\n") #define bitout(x,y) {\ cerr << #x << " : ";\ for (int justforbits = y; justforbits >=0; justforbits--)cout << (((1 << justforbits) & x)>=1);\ cout << "\n";\ } #define rangeout(j,rangestart,rangeend) {\ cerr << "outputting" << #j<< ":\n";\ for (int forrang = rangestart; forrang <= rangeend; forrang++)cerr << j[forrang] << " ";\ cerr<<"\n";\ } #define c1 {cerr << "Checkpoint 1! \n\n";cerr.flush();} #define c2 {cerr << "Checkpoint 2! \n\n";cerr.flush();} #define c3 {cerr << "Checkpoint 3! \n\n";cerr.flush();} #define c4 {cerr << "Checkpoint 4! \n\n";cerr.flush();} int curr; void dfs(int cn, vector<int>&preorder, vector<vector<int>>&adjlist) { preorder[cn]=++curr; for(int to:adjlist[cn]) { if(preorder[to]!=0)continue; dfs(to,preorder,adjlist); } } int findEgg (int n, vector<pii>bridges) { vector<int>preorder(n+1,0); vector<vector<int>>adjlist(n+1); for(int a=0;a<(n-1);a++) { auto[t1,t2]=bridges[a]; adjlist[t1].pb(t2); adjlist[t2].pb(t1); } curr=0; dfs(1,preorder,adjlist); int hi=n,lo=1,mid,ans; while(hi>=lo) { mid=(hi+lo)/2; vector<int>queset; for(int a=lo;a<=mid;a++){queset.pb(a);} if(query(queset)) { ans=mid; hi=mid-1; } else { lo=mid+1; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...