Submission #816338

# Submission time Handle Problem Language Result Execution time Memory
816338 2023-08-09T04:52:06 Z Jarif_Rahman Highway Tolls (IOI18_highway) C++17
12 / 100
193 ms 262144 KB
#include "highway.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int n, m;
ll A, B;
vector<vector<pair<int, int>>> graph;
vector<int> depth, p, pe;

void dfs(int nd, int dad, int dad_edge, int d){
    p[nd] = dad;
    depth[nd] = d;
    pe[nd] = dad_edge;
    for(auto [x, i]: graph[nd]) if(x != dad) dfs(x, nd, i, d+1);
}

void find_pair(int _n, vector<int> U, vector<int> V, int _A, int _B){
    swap(n, _n);
    int m = U.size();
    A = _A, B = _B;
    graph.resize(n);
    depth.resize(n);
    p.resize(n);
    pe.resize(n, -1);

    for(int i = 0; i < m; i++){
        graph[U[i]].pb({V[i], i});
        graph[V[i]].pb({U[i], i});
    }

    dfs(0, -1, -1, 0);
    vector<int> o(n);
    for(int i = 0; i < n; i++) o[i] = i;
    sort(o.begin(), o.end(), [&](int a, int b){
        return depth[a] > depth[b];
    });

    ll def = ask(vector<int>(m, 0));

    int a = 0, b = n-1;
    while(a < b){
        int md = (a+b)/2;
        vector<int> w(m, 0);
        for(int i = 0; i <= md; i++) if(pe[o[i]] != -1) w[pe[o[i]]] = 1;
        ll x = ask(w);
        if(x > def) b = md;
        else a = md+1;
    }

    answer(0, o[a]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 356 KB Output is correct
2 Correct 11 ms 1268 KB Output is correct
3 Correct 107 ms 8964 KB Output is correct
4 Correct 107 ms 8956 KB Output is correct
5 Correct 87 ms 8960 KB Output is correct
6 Correct 81 ms 8952 KB Output is correct
7 Correct 72 ms 8948 KB Output is correct
8 Correct 70 ms 8964 KB Output is correct
9 Correct 81 ms 8964 KB Output is correct
10 Correct 88 ms 8968 KB Output is correct
11 Correct 77 ms 9420 KB Output is correct
12 Correct 77 ms 9856 KB Output is correct
13 Correct 98 ms 9528 KB Output is correct
14 Correct 72 ms 9112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1648 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 193 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 181 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -