Submission #132019

# Submission time Handle Problem Language Result Execution time Memory
132019 2019-07-18T08:08:09 Z rondojim Highway Tolls (IOI18_highway) C++17
51 / 100
242 ms 9860 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 2424 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 5 ms 2552 KB Output is correct
2 Correct 25 ms 3112 KB Output is correct
3 Correct 224 ms 9624 KB Output is correct
4 Correct 207 ms 9612 KB Output is correct
5 Correct 231 ms 9676 KB Output is correct
6 Correct 195 ms 9620 KB Output is correct
7 Correct 224 ms 9708 KB Output is correct
8 Correct 227 ms 9632 KB Output is correct
9 Correct 194 ms 9756 KB Output is correct
10 Correct 208 ms 9616 KB Output is correct
11 Correct 211 ms 9068 KB Output is correct
12 Correct 227 ms 9080 KB Output is correct
13 Correct 225 ms 9068 KB Output is correct
14 Correct 221 ms 9064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3216 KB Output is correct
2 Correct 43 ms 3912 KB Output is correct
3 Correct 53 ms 4648 KB Output is correct
4 Correct 163 ms 9056 KB Output is correct
5 Correct 163 ms 9076 KB Output is correct
6 Correct 151 ms 9168 KB Output is correct
7 Correct 161 ms 9048 KB Output is correct
8 Correct 152 ms 9056 KB Output is correct
9 Correct 164 ms 9072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2576 KB Output is correct
2 Correct 24 ms 3200 KB Output is correct
3 Correct 163 ms 8096 KB Output is correct
4 Correct 225 ms 9688 KB Output is correct
5 Correct 192 ms 9616 KB Output is correct
6 Correct 207 ms 9636 KB Output is correct
7 Correct 234 ms 9608 KB Output is correct
8 Correct 215 ms 9608 KB Output is correct
9 Correct 214 ms 9648 KB Output is correct
10 Correct 235 ms 9616 KB Output is correct
11 Correct 227 ms 9064 KB Output is correct
12 Correct 229 ms 9060 KB Output is correct
13 Correct 228 ms 9056 KB Output is correct
14 Correct 232 ms 9148 KB Output is correct
15 Correct 215 ms 9620 KB Output is correct
16 Correct 203 ms 9628 KB Output is correct
17 Correct 221 ms 9068 KB Output is correct
18 Correct 242 ms 9164 KB Output is correct
19 Correct 216 ms 9720 KB Output is correct
20 Correct 215 ms 9076 KB Output is correct
21 Correct 181 ms 9860 KB Output is correct
22 Correct 156 ms 9768 KB Output is correct
23 Correct 187 ms 9840 KB Output is correct
24 Correct 206 ms 9280 KB Output is correct
25 Correct 230 ms 9156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 3064 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 3064 KB Incorrect
2 Halted 0 ms 0 KB -