Submission #1082152

# Submission time Handle Problem Language Result Execution time Memory
1082152 2024-08-30T19:20:42 Z TlenekWodoru Highway Tolls (IOI18_highway) C++17
51 / 100
133 ms 9788 KB
#include<bits/stdc++.h>
#include "highway.h"
using namespace std;
struct Edge
{
    int b,c;
};
vector<Edge>D[90009];
int n,m;
vector<int>E1,E2;
long long DeafOdl;
vector<int>BFS(int s)
{
    vector<int>ODL(n,-1);
    ODL[s]=0;
    deque<int>Y={s};
    vector<int>W;
    while((int)Y.size()>0)
    {
        const int v=Y[0];
        Y.pop_front();
        W.push_back(v);
        for(auto[som,ind] : D[v])
        {
            if(ODL[som]==-1)
            {
                ODL[som]=ODL[v]+1;
                Y.push_back(som);
            }
        }
    }
    return W;
}
int BinSearch()
{
    int l=0,p=n-1;
    while(l<p)
    {
        const int mid=(l+p)>>1;
        vector<int>Query(m);
        for(int i=0;i<mid;i++)
        {
            for(auto[som,ind] : D[i])
            {
                Query[ind]=1;
            }
        }
        if(ask(Query)!=DeafOdl)
        {
            p=mid;
        }
        else
        {
            l=mid+1;
        }
    }
    return l;
}
int BinSearch2(int s)
{
    vector<int>W=BFS(s);
    int l=0,p=n-1;
    while(l<p)
    {
        const int mid=(l+p+1)>>1;
        vector<int>Query(m);
        for(int i=mid;i<n;i++)
        {
            for(auto[som,ind] : D[W[i]])
            {
                Query[ind]=1;
            }
        }
        if(ask(Query)!=DeafOdl)
        {
            l=mid;
        }
        else
        {
            p=mid-1;
        }
    }
    return W[l];
}
void find_pair(int N, vector<int>EE1, vector<int>EE2, int A, int B)
{
    n=N;
    m=EE1.size();
    E1=EE1;
    E2=EE2;
    for(int i=0;i<m;i++)
    {
        D[E1[i]].push_back({E2[i],i});
        D[E2[i]].push_back({E1[i],i});
    }
    DeafOdl=ask(vector<int>(m));
    int u=BinSearch();
    int a=BinSearch2(u);
    int b=BinSearch2(a);
    if(a>b){swap(a,b);}
    answer(a,b);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 2 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2392 KB Output is correct
2 Correct 11 ms 3304 KB Output is correct
3 Correct 122 ms 9272 KB Output is correct
4 Correct 107 ms 9292 KB Output is correct
5 Correct 133 ms 9272 KB Output is correct
6 Correct 93 ms 9276 KB Output is correct
7 Correct 116 ms 9496 KB Output is correct
8 Correct 127 ms 9304 KB Output is correct
9 Correct 104 ms 9292 KB Output is correct
10 Correct 87 ms 9268 KB Output is correct
11 Correct 106 ms 8704 KB Output is correct
12 Correct 112 ms 8704 KB Output is correct
13 Correct 101 ms 8708 KB Output is correct
14 Correct 102 ms 9092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3160 KB Output is correct
2 Correct 15 ms 3928 KB Output is correct
3 Correct 28 ms 4468 KB Output is correct
4 Correct 69 ms 8696 KB Output is correct
5 Correct 75 ms 8724 KB Output is correct
6 Correct 70 ms 8696 KB Output is correct
7 Correct 78 ms 8708 KB Output is correct
8 Correct 69 ms 8692 KB Output is correct
9 Correct 75 ms 8700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 13 ms 3196 KB Output is correct
3 Correct 92 ms 7912 KB Output is correct
4 Correct 123 ms 9268 KB Output is correct
5 Correct 102 ms 9280 KB Output is correct
6 Correct 110 ms 9280 KB Output is correct
7 Correct 107 ms 9288 KB Output is correct
8 Correct 110 ms 9268 KB Output is correct
9 Correct 112 ms 9472 KB Output is correct
10 Correct 115 ms 9276 KB Output is correct
11 Correct 100 ms 8904 KB Output is correct
12 Correct 94 ms 8952 KB Output is correct
13 Correct 113 ms 9056 KB Output is correct
14 Correct 113 ms 8928 KB Output is correct
15 Correct 123 ms 9284 KB Output is correct
16 Correct 113 ms 9448 KB Output is correct
17 Correct 116 ms 8700 KB Output is correct
18 Correct 119 ms 9028 KB Output is correct
19 Correct 120 ms 9288 KB Output is correct
20 Correct 102 ms 8708 KB Output is correct
21 Correct 94 ms 9788 KB Output is correct
22 Correct 102 ms 9764 KB Output is correct
23 Correct 75 ms 9588 KB Output is correct
24 Correct 85 ms 9504 KB Output is correct
25 Correct 87 ms 8804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3160 KB Output is correct
2 Incorrect 15 ms 3144 KB Output is incorrect: {s, t} is wrong.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 3160 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -