Submission #836234

# Submission time Handle Problem Language Result Execution time Memory
836234 2023-08-24T09:00:41 Z mousebeaver Highway Tolls (IOI18_highway) C++14
0 / 100
6 ms 1848 KB
#define ll long long
#define pll pair<ll, ll>
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;

void dfs(vector<vector<pll>>& adjlist, vector<ll>& depth, vector<int>& upedge, int i)
{
    for(pll p : adjlist[i])
    {
        if(depth[p.first] == -1)
        {
            depth[p.first] = depth[i]+1;
            upedge[p.first] = p.second;
            dfs(adjlist, depth, upedge, p.first);
        }
    }
}

void find_pair(int n, std::vector<int> u, std::vector<int> v, int a, int b) 
{
    vector<vector<pll>> adjlist(n, vector<pll> (0));
    for(ll i = 0; i < n-1; i++)
    {
        adjlist[u[i]].push_back({v[i], i});
        adjlist[v[i]].push_back({u[i], i});
    }

    vector<ll> depth(n, -1);
    depth[0] = 0;
    vector<int> upedge(n, -1);
    dfs(adjlist, depth, upedge, 0);

    vector<int> w(n, 0);
    ll dist = ask(w)/a;
    vector<ll> c(0);
    for(ll i = 0; i < n; i++)
    {
        if(depth[i] == dist)
        {
            c.push_back(i);
        }
    }

    while(c.size() > 1)
    {
        int mid = (c.size())/2;
        w.assign(n, 0);
        for(int i = mid; i < (int) c.size(); i++)
        {
            w[upedge[i]] = 1;
        }

        if(ask(w) > dist)
        {
            vector<ll> s(0);
            for(int i = mid; i < (int) c.size(); i++)
            {
                s.push_back(c[i]);
            }
            c = s;
        }
        else
        {
            vector<ll> s(0);
            for(int i = 0; i < mid; i++)
            {
                s.push_back(c[i]);
            }
            c = s;
        }
    }
    answer(0, c[0]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1848 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1360 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1444 KB Incorrect
2 Halted 0 ms 0 KB -