Submission #1095873

#TimeUsernameProblemLanguageResultExecution timeMemory
1095873owoovoHighway Tolls (IOI18_highway)C++17
12 / 100
249 ms262144 KiB
#include "highway.h" #include<bits/stdc++.h> #define ll long long #define F first #define S second using namespace std; vector<pair<int,int>> e[90010]; vector<int> w; int n,dp[90010],toe[90010]; void dfs(int now,int last){ dp[now]=dp[last]+1; for(auto x:e[now]){ if(x.F==last)continue; toe[x.F]=x.S; dfs(x.F,now); } return; } void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { int M = U.size(); w.resize(M); for(auto x:w)x=0; for(int i=0;i<M;i++){ e[U[i]].push_back({V[i],i}); e[V[i]].push_back({U[i],i}); } dp[0]=-1; dfs(0,0); ll now=ask(w); ll need=now/A; vector<int> may; for(int i=0;i<N;i++){ if(dp[i]==need)may.push_back(i); } int l=0,r=may.size(); while(l<r-1){ int m=(l+r)>>1; //cout<<l<<" "<<r<<" "<<m<<"\n"; for(int i=0;i<M;i++)w[i]=0; for(int i=l;i<m;i++){ w[toe[may[i]]]=1; } ll ne=ask(w); if(ne!=now){ r=m; }else{ l=m; } } //cout<<may[l]<<"\n"; answer(0, may[l]); return; }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:22:12: warning: variable 'x' set but not used [-Wunused-but-set-variable]
   22 |   for(auto x:w)x=0;
      |            ^
#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...