Submission #1067902

#TimeUsernameProblemLanguageResultExecution timeMemory
1067902Faisal_SaqibHighway Tolls (IOI18_highway)C++17
5 / 100
83 ms9176 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long long long ask(const std::vector<int> &w); void answer(int s, int t); const ll NP=1e5; vector<pair<ll,ll>> ma[NP],tmp; vector<int> w; ll mi,a,b; int dfs(int x,int p=-1) { tmp.clear(); for(auto i:ma[x]) { if(i.second!=p) { tmp.pb(i); } } int s=-1; int e=tmp.size(); while(s+1<e) { int mid=(s+e)/2; for(int j=s+1;j<=mid;j++) w[tmp[j].first]=1; ll cost=ask(w); for(int j=s+1;j<=mid;j++) w[tmp[j].first]=0; if((cost>mi)) // edge is inside { e=mid; } else{ s=mid; } } if(e==(tmp.size())) { // no edge return x; } else { return dfs(tmp[e].second,x); } } void find_pair(int n, std::vector<int> u, std::vector<int> v, int A, int B) { int m=u.size(); w.resize(m,0); a=A; b=B; mi=ask(w); for(int i=0;i<m;i++) { ma[u[i]].pb({i,v[i]}); ma[v[i]].pb({i,u[i]}); } answer(0,dfs(0)); }

Compilation message (stderr)

highway.cpp: In function 'int dfs(int, int)':
highway.cpp:39:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  if(e==(tmp.size()))
      |     ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...