Submission #102973

# Submission time Handle Problem Language Result Execution time Memory
102973 2019-03-28T09:46:36 Z daniel920712 Highway Tolls (IOI18_highway) C++14
0 / 100
28 ms 6228 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <utility>
#include "highway.h"
using namespace std;
vector < int > how;
vector < int > a,b;
vector < pair < int , int > > road[90005];
int n,m,x=-1,y=-1;
long long t;
bool have_V[90005]={0};
bool have_E[130005]={0};
int F(int l,int r)
{
    int i;
    for(i=l;i<=(l+r)/2;i++) how[i]=1;
    if(ask(how)>t)
    {
        for(i=0;i<=(l+r)/2;i++) how[i]=0;
        if(l==r) return l;
        else return F(l,(l+r)/2);

    }
    else
    {
        for(i=l;i<=(l+r)/2;i++) how[i]=0;
        if(l==r) return -1;
        else return F((l+r)/2+1,r);
    }
}
void Find1(int here)
{
    for(auto i:road[here])
    {
        if(!have_V[i.first])
        {
            a.push_back(i.second);
            have_V[i.first]=1;
            Find1(i.second);
        }

    }
}
void Find2(int here)
{
    for(auto i:road[here])
    {
        if(!have_V[i.first])
        {
            b.push_back(i.second);
            have_V[i.first]=1;
            Find2(i.second);
        }

    }
}

int Ans1(int l,int r)
{
    int i;
    for(i=l;i<=(l+r)/2;i++) how[a[i]]=1;
    if(ask(how)>t)
    {
        for(i=0;i<=(l+r)/2;i++) how[a[i]]=0;
        if(l==r) return a[l];
        else return Ans1(l,(l+r)/2);

    }
    else
    {
        for(i=l;i<=(l+r)/2;i++) how[a[i]]=0;
        if(l==r) return -1;
        else return Ans1((l+r)/2+1,r);
    }
}

int Ans2(int l,int r)
{
    int i;
    for(i=l;i<=(l+r)/2;i++) how[b[i]]=1;
    if(ask(how)>t)
    {
        for(i=0;i<=(l+r)/2;i++) how[b[i]]=0;
        if(l==r) return b[l];
        else return Ans2(l,(l+r)/2);

    }
    else
    {
        for(i=l;i<=(l+r)/2;i++) how[b[i]]=0;
        if(l==r) return -1;
        else return Ans2((l+r)/2+1,r);
    }
}


void find_pair(int N,vector < int > U,vector < int > V,int A,int B)
{
    int i,edge;
    n=N;
    m=U.size();
    for(i=0;i<m;i++) how.push_back(0);
    for(i=0;i<n;i++)
    {
        road[U[i]].push_back(make_pair(V[i],i));
        road[V[i]].push_back(make_pair(U[i],i));
    }
    t=ask(how);
    edge=F(0,m-1);
    have_V[U[edge]]=1;
    have_V[V[edge]]=1;
    Find1(U[edge]);
    Find2(V[edge]);
    x=Ans1(0,a.size()-1);
    y=Ans2(0,b.size()-1);
    answer(x,y);
    //printf("%d\n",edge);
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2344 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 4856 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 2952 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 4792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 6228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 3208 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -