Submission #804701

# Submission time Handle Problem Language Result Execution time Memory
804701 2023-08-03T10:54:41 Z 1bin Highway Tolls (IOI18_highway) C++14
0 / 100
16 ms 4396 KB
#include <bits/stdc++.h>
#include "highway.h"

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1e5 + 5;
ll n, m, lv[NMAX], cost;
vector<pair<int, int>> adj[NMAX], od;

void dfs(int x){
    for(auto&[nx, e] : adj[x])
        if(!lv[nx]){
            lv[nx] = lv[x] + 1;
            dfs(nx);
        }
    return;
}

int find(int rt){
    od.clear();
    memset(lv, 0, sizeof(lv));
    lv[rt] = 1; dfs(rt);
    int l = 0, r = n - 1, mid;
    while(l < r){
        mid = (l + r) / 2;
        vector<int> w(m, 0);
        for(int i = mid + 1; i <= r; i++) 
            for(auto&[j, e] : adj[i])
                if(lv[j] < lv[i]) w[e] = 1;
        if(ask(w) > cost) l = mid + 1;
        else r = mid;
    }
    return l;
}

void find_pair(int n_, vector<int> U, std::vector<int> V, int A, int B) {
    n = n_; m = U.size();
    for(int i = 0; i < m; i++){
        adj[U[i]].emplace_back(V[i], i);
        adj[V[i]].emplace_back(U[i], i);
    }
    cost = ask(vector<int>(m, 0));
    int s = find(1);
    int t = find(s);
	answer(s, t);
    return;
}

Compilation message

highway.cpp: In function 'void dfs(int)':
highway.cpp:13:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   13 |     for(auto&[nx, e] : adj[x])
      |              ^
highway.cpp: In function 'int find(int)':
highway.cpp:30:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |             for(auto&[j, e] : adj[i])
      |                      ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3420 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3404 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 4396 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3408 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 4124 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 4016 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -