Submission #918918

#TimeUsernameProblemLanguageResultExecution timeMemory
918918MoonnEaster Eggs (info1cup17_eastereggs)C++17
0 / 100
2 ms812 KiB
#include<bits/stdc++.h> #define inti long long #define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; vector<vector<int>>v; vector<bool>ch; vector<int>g; int query(vector<int> islands); void dfs(int n,int x) { ch[x]=1; for(int i:v[x]) { if(!ch[i]) dfs(n,i); } g.push_back(x); } int findEgg(int n, vector < pair < int, int > > bridges) { v.resize(n+1); ch.resize(n+1,0); for(int i=0;i<bridges.size();i++) { int a=bridges[i].first; int b=bridges[i].second; v[a].push_back(b); v[b].push_back(a); } dfs(n,1); int l,r,mid; l=0; r=g.size()-1; vector<int>vi; while(l<r) { vi.clear(); mid=(l+r)/2; for(int i=0;i<=mid;i++) vi.push_back(g[i]); if(query(vi)) r=mid; else l=mid+1; } return g[r]; }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:23: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]
   23 |     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...