# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1095873 | owoovo | Highway Tolls (IOI18_highway) | C++17 | 249 ms | 262144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |