Submission #804752

# Submission time Handle Problem Language Result Execution time Memory
804752 2023-08-03T11:09:00 Z 1bin Highway Tolls (IOI18_highway) C++14
0 / 100
15 ms 4392 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];
vector<int> od;


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

int find(int rt){
    od.clear();
    memset(lv, 0, sizeof(lv));
    lv[rt] = 1; dfs(rt);
    for(int i = 0; i < n; i++) cout << od[i] << ' ';
    cout << '\n';
    int l = 0, r = n - 1, mid;
    while(l < r){
        mid = (l + r) / 2;
        vector<int> w(m, 0);
        for(int i = l; i <= mid; i++) 
            for(auto&[j, e] : adj[od[i]])
                if(lv[j] < lv[od[i]]) w[e] = 1;
        if(ask(w) > cost) r = mid;
        else l = mid + 1;
    }
    return od[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(0);
    cout << "vertex one is " << s << '\n';
    int t = find(s);
	answer(s, t);
    return;
}

Compilation message

highway.cpp: In function 'void dfs(int)':
highway.cpp:15:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |     for(auto&[nx, e] : adj[x])
      |              ^
highway.cpp: In function 'int find(int)':
highway.cpp:35:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   35 |             for(auto&[j, e] : adj[od[i]])
      |                      ^
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 3432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 3408 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 4392 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 3408 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 4140 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 4176 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -