Submission #818294

# Submission time Handle Problem Language Result Execution time Memory
818294 2023-08-10T04:18:55 Z Jarif_Rahman Highway Tolls (IOI18_highway) C++17
51 / 100
133 ms 9176 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;

ll def;

int find_node(int root){
    vector<int> dis(n, -1);
    queue<int> Q;
    dis[root] = 0;
    Q.push(root);
    vector<int> p(n, -1);
    while(!Q.empty()){
        int nd = Q.front(); Q.pop();
        for(auto [x, i]: graph[nd]) if(dis[x] == -1){
            dis[x] = dis[nd]+1;
            p[x] = i;
            Q.push(x);
        }
    }

    vector<int> o(n);
    for(int i = 0; i < n; i++) o[i] = i;
    sort(o.begin(), o.end(), [&](int a, int b){
        return dis[a] > dis[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(p[o[i]] != -1) w[p[o[i]]] = 1;
        ll x = ask(w);
        if(x > def) b = md;
        else a = md+1;
    }

    return o[a];
}

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

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

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

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

    int nd = U[a];
    int s = find_node(nd);
    int t = find_node(s);
    answer(s, t);
}
# 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 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 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 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 380 KB Output is correct
2 Correct 11 ms 1112 KB Output is correct
3 Correct 107 ms 8700 KB Output is correct
4 Correct 112 ms 8652 KB Output is correct
5 Correct 123 ms 8740 KB Output is correct
6 Correct 109 ms 8648 KB Output is correct
7 Correct 112 ms 8684 KB Output is correct
8 Correct 111 ms 8652 KB Output is correct
9 Correct 97 ms 8740 KB Output is correct
10 Correct 94 ms 8656 KB Output is correct
11 Correct 123 ms 8048 KB Output is correct
12 Correct 107 ms 8056 KB Output is correct
13 Correct 124 ms 8060 KB Output is correct
14 Correct 110 ms 8060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1140 KB Output is correct
2 Correct 23 ms 2040 KB Output is correct
3 Correct 30 ms 2860 KB Output is correct
4 Correct 74 ms 8068 KB Output is correct
5 Correct 133 ms 8060 KB Output is correct
6 Correct 103 ms 8044 KB Output is correct
7 Correct 67 ms 8056 KB Output is correct
8 Correct 98 ms 8048 KB Output is correct
9 Correct 86 ms 8088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 13 ms 1140 KB Output is correct
3 Correct 70 ms 6808 KB Output is correct
4 Correct 122 ms 8644 KB Output is correct
5 Correct 85 ms 8648 KB Output is correct
6 Correct 106 ms 8656 KB Output is correct
7 Correct 127 ms 8656 KB Output is correct
8 Correct 83 ms 8636 KB Output is correct
9 Correct 96 ms 8656 KB Output is correct
10 Correct 118 ms 8656 KB Output is correct
11 Correct 121 ms 8056 KB Output is correct
12 Correct 123 ms 8052 KB Output is correct
13 Correct 111 ms 8060 KB Output is correct
14 Correct 122 ms 8080 KB Output is correct
15 Correct 86 ms 8668 KB Output is correct
16 Correct 89 ms 8656 KB Output is correct
17 Correct 115 ms 8064 KB Output is correct
18 Correct 121 ms 8060 KB Output is correct
19 Correct 111 ms 8664 KB Output is correct
20 Correct 128 ms 8064 KB Output is correct
21 Correct 81 ms 9140 KB Output is correct
22 Correct 84 ms 9176 KB Output is correct
23 Correct 82 ms 8940 KB Output is correct
24 Correct 90 ms 8908 KB Output is correct
25 Correct 123 ms 8172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1152 KB Output is correct
2 Correct 17 ms 1404 KB Output is correct
3 Incorrect 96 ms 9024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1232 KB Output is correct
2 Correct 10 ms 1200 KB Output is correct
3 Incorrect 133 ms 9068 KB Output isn't correct
4 Halted 0 ms 0 KB -