Submission #785333

# Submission time Handle Problem Language Result Execution time Memory
785333 2023-07-17T08:28:21 Z drdilyor Highway Tolls (IOI18_highway) C++17
12 / 100
96 ms 7760 KB
#include <bits/stdc++.h>
#include "highway.h"
#ifdef ONPC
    #include "t_debug.cpp"
#else
    #define debug(...) 42
#endif
using namespace std;
//namespace pbds = __gnu_pbds;
using ll = long long;
const int inf = 1e9;
const ll infl = 1e18;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; }
template<typename Cont> int sz(const Cont& cont) { return int(cont.size()); }
template<typename Func> struct ycom { Func f; template<typename... T> auto operator()(T&&... args) { return f(*this, args...); } }; template<typename Func> ycom(Func) -> ycom<Func>;
template<typename T> typename vector<T>::iterator operator+(const vector<T>& x, int i) { return x.begin() + i ;};
const string fileio = "";
constexpr int tests = 1, nmax = 2e5, nlog = __lg(nmax), mod = 1e9+7;

void find_pair(int32_t n, std::vector<int32_t> u, std::vector<int32_t> v, int32_t a, int32_t b) {
    int m = u.size();
    vector<vector<pair<int,int>>> adj(n);

    for (int i = 0; i < m; i++) {
        adj[u[i]].emplace_back(v[i], i);
        adj[v[i]].emplace_back(u[i], i);
    }

    ll base = ask(vector(m, 0));
    int len = base / a;

    vector<pair<int,int>> level;
    auto dfs = [&](auto& dfs, int i, int p, int dep)->void{
        for (auto [e, ei] : adj[i]) {
            if (e == p) continue;
            if (dep+1 == len) {
                level.emplace_back(e, ei);
                continue;
            }
            dfs(dfs, e, i, dep+1);
        }
    };
    dfs(dfs, 0, -1, 0);

    int l = 0, r = level.size()-1;
    while (l < r) {
        int mid = (l + r) / 2;
        vector<int> w(m);
        for (int i = l; i <= mid; i++) {
            w[level[i].second] = 1;
        }
        ll toll = ask(w);
        assert(toll == base || toll == base - a + b);
        if (toll == base) {
            l = mid+1;
        } else r = mid;
    }
    answer(0, level[l].first);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 380 KB Output is correct
2 Correct 7 ms 1104 KB Output is correct
3 Correct 84 ms 7680 KB Output is correct
4 Correct 96 ms 7700 KB Output is correct
5 Correct 79 ms 7752 KB Output is correct
6 Correct 89 ms 7488 KB Output is correct
7 Correct 67 ms 7552 KB Output is correct
8 Correct 62 ms 7748 KB Output is correct
9 Correct 60 ms 7556 KB Output is correct
10 Correct 61 ms 7760 KB Output is correct
11 Correct 71 ms 7048 KB Output is correct
12 Correct 57 ms 7352 KB Output is correct
13 Correct 70 ms 7276 KB Output is correct
14 Correct 55 ms 7440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1016 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 3324 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 2300 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -