Submission #1068391

# Submission time Handle Problem Language Result Execution time Memory
1068391 2024-08-21T09:39:03 Z mc061 Highway Tolls (IOI18_highway) C++17
5 / 100
9 ms 892 KB
#include <bits/stdc++.h>
using namespace std;

int m;

long long ask(const std::vector<int> &w);
long long get(const vector<int>& busy) {
    vector<int> q(m, 0);
    for (int i : busy) q[i] = 1;
    return ask(q);
}
void answer(int s, int t);

void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
    m = U.size();
    vector<int> v(U.size());
    iota(v.begin(), v.end(), 0);
    vector<vector<int>> full;
    int path_le = get(v) / B;
    auto rec = [&] (auto&& self, vector<int> now) -> void {
        long long here = get(now);
        if (here == 1ll*path_le*A) return;
        if (here == 1ll*now.size()*B + 1ll*(path_le-now.size())*A) {
            full.push_back(now);
            return;
        }
        random_shuffle(now.begin(), now.end());
        vector<int> left, right;
        for (int i = 0; i < now.size()/2; ++i) {
            left.push_back(now[i]);
        }
        for (int i = now.size()/2; i < now.size(); ++i) {
            right.push_back(now[i]);
        }
        self(self, left);
        self(self, right);
    };
    rec(rec, v);
    map<int, int> c;
    for (auto& x : full) {
        for (int j : x) {
            c[U[j]]++;
            c[V[j]]++;
        }
    }
    vector<int> vs;
    for (auto [x, y] : c) {
        if (y == 1) vs.push_back(x);
    }
    answer(vs[0], vs[1]);
}

Compilation message

highway.cpp: In lambda function:
highway.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int i = 0; i < now.size()/2; ++i) {
      |                         ~~^~~~~~~~~~~~~~
highway.cpp:32:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for (int i = now.size()/2; i < now.size(); ++i) {
      |                                    ~~^~~~~~~~~~~~
highway.cpp: In instantiation of 'find_pair(int, std::vector<int>, std::vector<int>, int, int)::<lambda(auto:23&&, std::vector<int>)> [with auto:23 = find_pair(int, std::vector<int>, std::vector<int>, int, int)::<lambda(auto:23&&, std::vector<int>)>&]':
highway.cpp:38:15:   required from here
highway.cpp:23:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   23 |         if (here == 1ll*now.size()*B + 1ll*(path_le-now.size())*A) {
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
highway.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int i = 0; i < now.size()/2; ++i) {
      |                         ~~^~~~~~~~~~~~~~
highway.cpp:32:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for (int i = now.size()/2; i < now.size(); ++i) {
      |                                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 764 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 856 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 892 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -