| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 140330 | XmtosX | Highway Tolls (IOI18_highway) | C++17 | 1433 ms | 262148 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>
using namespace std;
const int MAXN=90005;
int n,m,par[MAXN];
vector <int> v[MAXN];
vector <pair<int,int> > vv;
map <pair<int,int>, int> r;
long long ANS;
bool block[MAXN];
void dfs (int x,int p,int l)
{
    vv.push_back({l,x});
    par[x]=p;
    for (int i=0;i<v[x].size();i++)
    {
        if (v[x][i]!=p&&!block[v[x][i]])
        {
            dfs(v[x][i],x,l+1);
        }
    }
}
void find_pair (int N, vector<int> U, vector<int> V, int A, int B)
{
    n=N;
    m=U.size();
    vector<int> w;
    w.resize(m);
    ANS=ask(w);
    int low=0,high=m-1,ans,mid;
    while (low<=high)
    {
        mid=(high+low)/2;
        if (low==high)
        {
            ans=mid;
            break;
        }
        if (mid==low)
            mid++;
        for (int i=0;i<m;i++)
            w[i]=0;
        for (int i=mid;i<=high;i++)
        {
            w[i]=1;
        }
        if (ANS!=ask(w))
        {
            low=mid;
        }
        else
            high=mid-1;
    }
    for (int i=0;i<m;i++)
    {
        v[U[i]].push_back(V[i]);
        v[V[i]].push_back(U[i]);
        r[{U[i],V[i]}]=i;
        r[{V[i],U[i]}]=i;
    }
    block[U[ans]]=1;
    block[V[ans]]=1;
    int an[2];
    int u[2]={U[ans],V[ans]};
    for (int q=0;q<2;q++)
    {
        vv.clear();
        dfs(u[q],u[1-q],1);
        if (vv.size()==1)
        {
            an[q]=vv[0].second;
            continue;
        }
        low=0,high=vv.size(),mid,ans=-1;
        while (low<=high)
        {
            for (int i=0;i<w.size();i++)
                w[i]=0;
            mid=(low+high)/2;
            for (int i=mid;i<vv.size();i++)
            {
                int a=vv[i].second;
                w[r[{a,par[a]}]]=1;
            }
            if (ask(w)!=ANS)
            {
                ans=vv[mid].second;
                low=mid+1;
            }
            else
                high=mid-1;
        }
        an[q]=ans;
    }
    answer(an[0],an[1]);
}
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... | ||||
