Submission #498740

#TimeUsernameProblemLanguageResultExecution timeMemory
498740ahmedfouadnewEaster Eggs (info1cup17_eastereggs)C++17
0 / 100
2 ms584 KiB
#include <bits/stdc++.h> #include "grader.h" //#include "grader.cpp" #define pb push_back #define f first #define s second using namespace std; vector<int>adj[606]; int n; vector<int>vv; void dfs(int u,int p) { vv.pb(u); for(int v:adj[u]) { if(v==p) continue; dfs(v,u); vv.pb(u); } } int findEgg (int N, vector < pair < int, int > > bridges) { if(N==1) return 1; for(int i=0;i<=N;i++) { adj[i].clear(); } vv.clear(); n=N; for(int i=0;i<bridges.size();i++) { adj[bridges[i].f].pb(bridges[i].s); adj[bridges[i].s].pb(bridges[i].f); } dfs(1,0); int s=0,e=vv.size()-2; while(s<e) { int mid=s+(e-s+1)/2; set<int>st; for(int i=s;i<=e;i++) { st.insert(vv[i]); } if(st.size()==1) return vv[s]; st.clear(); for(int ii=s;ii<=mid;ii++) st.insert(vv[ii]); vector<int>qr(st.begin(),st.end()); if(query(qr)) { e=mid; } else { s=mid+1; } } return vv[s]; }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<bridges.size();i++)
      |                 ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...