Submission #117628

# Submission time Handle Problem Language Result Execution time Memory
117628 2019-06-16T20:21:26 Z Osama_Alkhodairy Highway Tolls (IOI18_highway) C++17
51 / 100
253 ms 9780 KB
#include <bits/stdc++.h>
#include "highway.h"
//#include "grader.cpp"
using namespace std;
#define ll long long

int n;
vector <pair <int, int> > es, g[90001];
ll light;

int find(int root){
    vector <bool> vis(n);
    queue <int> ready;
    vector <int> depth(n);
    ready.push(root);
    vector <int> edges;
    while(ready.size()){
        int node = ready.front();
        vis[node] = 1;
        ready.pop();
        for(auto &i : g[node]){
            if(vis[i.first]) continue;
            depth[i.first] = depth[node] + 1;
            edges.push_back(i.second);
            ready.push(i.first);
        }
    }
    reverse(edges.begin(), edges.end());
    int l = 0, r = n - 1;
    while(l <= r){
        int mid = (l + r) / 2;
        vector <int> check(n - 1);
        for(int i = 0 ; i <= mid ; i++){
            check[edges[i]] = 1;
        }
        if(ask(check) != light) r = mid - 1;
        else l = mid + 1;
    }
    auto edge = es[edges[l]];
    if(depth[edge.first] > depth[edge.second]) return edge.first;
    return edge.second;
}
void find_pair(int N, std::vector<int> u, std::vector<int> v, int a, int b) {
    n = N;
    for(int i = 0 ; i < n - 1 ; i++){
        g[u[i]].push_back(make_pair(v[i], i));
        g[v[i]].push_back(make_pair(u[i], i));
        es.push_back(make_pair(u[i], v[i]));
    }
    light = ask(vector <int>(n - 1, 0));
    int s = find(0);
    int t = find(s);
    answer(s, t);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2424 KB Output is correct
2 Correct 4 ms 2344 KB Output is correct
3 Correct 4 ms 2424 KB Output is correct
4 Correct 4 ms 2424 KB Output is correct
5 Correct 4 ms 2424 KB Output is correct
6 Correct 4 ms 2424 KB Output is correct
7 Correct 4 ms 2424 KB Output is correct
8 Correct 4 ms 2424 KB Output is correct
9 Correct 4 ms 2424 KB Output is correct
10 Correct 4 ms 2424 KB Output is correct
11 Correct 4 ms 2424 KB Output is correct
12 Correct 4 ms 2424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2552 KB Output is correct
2 Correct 25 ms 3192 KB Output is correct
3 Correct 223 ms 9696 KB Output is correct
4 Correct 221 ms 9624 KB Output is correct
5 Correct 194 ms 9608 KB Output is correct
6 Correct 198 ms 9616 KB Output is correct
7 Correct 213 ms 9636 KB Output is correct
8 Correct 212 ms 9604 KB Output is correct
9 Correct 203 ms 9616 KB Output is correct
10 Correct 208 ms 9736 KB Output is correct
11 Correct 212 ms 9172 KB Output is correct
12 Correct 225 ms 9064 KB Output is correct
13 Correct 220 ms 9128 KB Output is correct
14 Correct 229 ms 9092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 3124 KB Output is correct
2 Correct 35 ms 3940 KB Output is correct
3 Correct 54 ms 4640 KB Output is correct
4 Correct 170 ms 9144 KB Output is correct
5 Correct 171 ms 9164 KB Output is correct
6 Correct 166 ms 9168 KB Output is correct
7 Correct 181 ms 9052 KB Output is correct
8 Correct 171 ms 9056 KB Output is correct
9 Correct 167 ms 9076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2424 KB Output is correct
2 Correct 24 ms 3136 KB Output is correct
3 Correct 157 ms 8100 KB Output is correct
4 Correct 214 ms 9632 KB Output is correct
5 Correct 225 ms 9656 KB Output is correct
6 Correct 196 ms 9624 KB Output is correct
7 Correct 220 ms 9632 KB Output is correct
8 Correct 224 ms 9608 KB Output is correct
9 Correct 219 ms 9696 KB Output is correct
10 Correct 219 ms 9708 KB Output is correct
11 Correct 221 ms 9068 KB Output is correct
12 Correct 222 ms 9068 KB Output is correct
13 Correct 253 ms 9068 KB Output is correct
14 Correct 213 ms 9096 KB Output is correct
15 Correct 176 ms 9652 KB Output is correct
16 Correct 209 ms 9624 KB Output is correct
17 Correct 225 ms 9108 KB Output is correct
18 Correct 218 ms 9072 KB Output is correct
19 Correct 231 ms 9632 KB Output is correct
20 Correct 210 ms 9132 KB Output is correct
21 Correct 183 ms 9768 KB Output is correct
22 Correct 186 ms 9780 KB Output is correct
23 Correct 196 ms 9780 KB Output is correct
24 Correct 197 ms 9384 KB Output is correct
25 Correct 226 ms 9144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 3020 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 3024 KB Incorrect
2 Halted 0 ms 0 KB -