Submission #103062

# Submission time Handle Problem Language Result Execution time Memory
103062 2019-03-29T01:26:15 Z daniel920712 Highway Tolls (IOI18_highway) C++14
51 / 100
303 ms 10976 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <utility>
#include <queue>
#include "highway.h"
using namespace std;
vector < int > how;
vector < pair < int , 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)
{
    if(l==r) return l;
    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 l;
        else return F((l+r)/2+1,r);
    }
}
int Ans1(int l,int r)
{
    int i;
    if(l==r) return a[l].second;
    for(i=(l+r)/2+1;i<=r;i++) how[a[i].first]=1;
    if(ask(how)==t)
    {
        for(i=(l+r)/2+1;i<=r;i++) how[a[i].first]=0;
        return Ans1(l,(l+r)/2);
    }
    else
    {
        for(i=(l+r)/2+1;i<=r;i++) how[a[i].first]=0;
        return Ans1((l+r)/2+1,r);
    }
}
int Ans2(int l,int r)
{
    int i;
    if(l==r) return b[l].second;
    for(i=(l+r)/2+1;i<=r;i++) how[b[i].first]=1;
    if(ask(how)==t)
    {
        for(i=(l+r)/2+1;i<=r;i++) how[b[i].first]=0;
        return Ans2(l,(l+r)/2);
    }
    else
    {
        for(i=(l+r)/2+1;i<=r;i++) how[b[i].first]=0;
        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,here,x;
    n=N;
    m=U.size();
    for(i=0;i<m;i++) how.push_back(0);
    for(i=0;i<m;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;
    have_E[edge]=1;
    a.push_back(make_pair(edge,U[edge]));
    b.push_back(make_pair(edge,V[edge]));

    queue < pair < int , int > > temp;
    temp.push(make_pair(U[edge],0));
    temp.push(make_pair(V[edge],1));
    while(!temp.empty())
    {
        here=temp.front().first;
        x=temp.front().second;
        temp.pop();
        for(auto i:road[here])
        {
            if(!have_V[i.first])
            {
                have_V[i.first]=1;
                have_E[i.second]=1;
                temp.push(make_pair(i.first,x));
                if(x) b.push_back(make_pair(i.second,i.first));
                else a.push_back(make_pair(i.second,i.first));
            }

        }
    }


    for(i=0;i<m;i++) if(!have_E[i]) how[i]=1;
    x=Ans1(0,a.size()-1);
    y=Ans2(0,b.size()-1);
    answer(x,y);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2424 KB Output is correct
2 Correct 4 ms 2424 KB Output is correct
3 Correct 4 ms 2436 KB Output is correct
4 Correct 4 ms 2436 KB Output is correct
5 Correct 4 ms 2424 KB Output is correct
6 Correct 4 ms 2436 KB Output is correct
7 Correct 4 ms 2344 KB Output is correct
8 Correct 4 ms 2440 KB Output is correct
9 Correct 4 ms 2524 KB Output is correct
10 Correct 4 ms 2424 KB Output is correct
11 Correct 4 ms 2516 KB Output is correct
12 Correct 4 ms 2436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2488 KB Output is correct
2 Correct 24 ms 3192 KB Output is correct
3 Correct 205 ms 8944 KB Output is correct
4 Correct 199 ms 8948 KB Output is correct
5 Correct 168 ms 8944 KB Output is correct
6 Correct 178 ms 8940 KB Output is correct
7 Correct 199 ms 8956 KB Output is correct
8 Correct 218 ms 8936 KB Output is correct
9 Correct 178 ms 8948 KB Output is correct
10 Correct 208 ms 8948 KB Output is correct
11 Correct 198 ms 8472 KB Output is correct
12 Correct 186 ms 8548 KB Output is correct
13 Correct 191 ms 8308 KB Output is correct
14 Correct 237 ms 8692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3188 KB Output is correct
2 Correct 42 ms 3724 KB Output is correct
3 Correct 45 ms 4492 KB Output is correct
4 Correct 163 ms 8296 KB Output is correct
5 Correct 164 ms 8368 KB Output is correct
6 Correct 165 ms 8700 KB Output is correct
7 Correct 148 ms 8340 KB Output is correct
8 Correct 168 ms 8440 KB Output is correct
9 Correct 156 ms 8524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2488 KB Output is correct
2 Correct 36 ms 3196 KB Output is correct
3 Correct 169 ms 7820 KB Output is correct
4 Correct 182 ms 8928 KB Output is correct
5 Correct 180 ms 8920 KB Output is correct
6 Correct 183 ms 8952 KB Output is correct
7 Correct 166 ms 8940 KB Output is correct
8 Correct 187 ms 8944 KB Output is correct
9 Correct 187 ms 8952 KB Output is correct
10 Correct 197 ms 8976 KB Output is correct
11 Correct 191 ms 8380 KB Output is correct
12 Correct 209 ms 8816 KB Output is correct
13 Correct 193 ms 8964 KB Output is correct
14 Correct 216 ms 8412 KB Output is correct
15 Correct 173 ms 8948 KB Output is correct
16 Correct 160 ms 8940 KB Output is correct
17 Correct 206 ms 8832 KB Output is correct
18 Correct 190 ms 8344 KB Output is correct
19 Correct 163 ms 8936 KB Output is correct
20 Correct 167 ms 8468 KB Output is correct
21 Correct 166 ms 9692 KB Output is correct
22 Correct 158 ms 9652 KB Output is correct
23 Correct 160 ms 9264 KB Output is correct
24 Correct 164 ms 9200 KB Output is correct
25 Correct 208 ms 8944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3200 KB Output is correct
2 Correct 29 ms 3320 KB Output is correct
3 Correct 222 ms 9596 KB Output is correct
4 Correct 240 ms 10164 KB Output is correct
5 Correct 303 ms 10968 KB Output is correct
6 Incorrect 257 ms 10976 KB Output is incorrect: {s, t} is wrong.
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 3100 KB Output is correct
2 Correct 29 ms 3212 KB Output is correct
3 Correct 214 ms 9512 KB Output is correct
4 Incorrect 201 ms 9808 KB Output is incorrect: {s, t} is wrong.
5 Halted 0 ms 0 KB -