제출 #348478

#제출 시각아이디문제언어결과실행 시간메모리
348478juggernaut통행료 (IOI18_highway)C++14
12 / 100
168 ms9740 KiB
#include"highway.h"
#include<bits/stdc++.h>
#ifndef EVAL
#include"grader.cpp"
#endif
using namespace std;
vector<pair<int,int>>g[90005];
bool is[90005];
int under[90005];
long long pivot;
void dfs(int v,int p,int depth){
    for(auto to:g[v])if(to.first!=p){
        if(depth+1==pivot)is[to.second]=1;
        under[to.second]=to.first;
        dfs(to.first,v,depth+1);
    }
}
void find_pair(int n,vector<int>x,vector<int>y,int a,int b){
    vector<int>v(n-1,0);
    pivot=ask(v)/a;
    for(int i=0;i+1<n;i++){
        g[x[i]].push_back({y[i],i});
        g[y[i]].push_back({x[i],i});
    }
    dfs(0,0,0);
    int l=0,r=n-2;
    while(l<r){
        int mid=(l+r)>>1;
        vector<int>v(n-1,0);
        for(int i=l;i<=mid;i++)v[i]=is[i];
        if(ask(v)!=pivot*a)r=mid;
        else l=mid+1;
    }
    answer(0,under[l]);
}
/*
5 4 1 2 0 4
0 1
0 2
1 3
1 4
*/
#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...