Submission #964223

# Submission time Handle Problem Language Result Execution time Memory
964223 2024-04-16T12:49:29 Z tmarcinkevicius Highway Tolls (IOI18_highway) C++14
Compilation error
0 ms 0 KB
#include "highway.h"
using namespace std;

int N, M, A, B;
vector<pii> Edges;
int distance;

pii BlockedEdge;

void FindBlockedEdge()
{
    int low = 0;
    int high = M - 1;

    int w[M];
    fill(w, w + M, 0);
    int firstValue = ask(w);


    while (low < high)
    {
        int mid = low + (high - low + 1) / 2;

        int w[M];
        for (int i = 0; i < M; i++)
        {
            w[i] = !(i >= low && i < mid);
        }

        int64_t result = ask(w);

        if (result < firstValue)
        {
            high = mid - 1;
        }
        else
        {
            low = mid;
        }
    }

    cout << "Found (" << Edges[low].f << ", " << Edges[low].s << ")\n";
}

void find_pair(int n, vector<int> u, vector<int> v, int a, int b)
{
    N = n;
    A = a;
    B = b;
    M = u.size();

    for (int i = 0; i < M; ++i)
    {
        Edges.push_back({u[i], v[i]});
    }

    int w[M];
    fill(w, w + M, 0);

    distance = ask(w) / A;
}


Compilation message

highway.cpp:5:8: error: 'pii' was not declared in this scope
    5 | vector<pii> Edges;
      |        ^~~
highway.cpp:5:11: error: template argument 1 is invalid
    5 | vector<pii> Edges;
      |           ^
highway.cpp:5:11: error: template argument 2 is invalid
highway.cpp:8:1: error: 'pii' does not name a type
    8 | pii BlockedEdge;
      | ^~~
highway.cpp: In function 'void FindBlockedEdge()':
highway.cpp:17:26: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'int [M]'
   17 |     int firstValue = ask(w);
      |                          ^
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp:30:9: error: 'int64_t' was not declared in this scope
   30 |         int64_t result = ask(w);
      |         ^~~~~~~
highway.cpp:32:13: error: 'result' was not declared in this scope
   32 |         if (result < firstValue)
      |             ^~~~~~
highway.cpp:42:5: error: 'cout' was not declared in this scope
   42 |     cout << "Found (" << Edges[low].f << ", " << Edges[low].s << ")\n";
      |     ^~~~
highway.cpp:2:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    1 | #include "highway.h"
  +++ |+#include <iostream>
    2 | using namespace std;
highway.cpp:42:31: error: invalid types 'int[int]' for array subscript
   42 |     cout << "Found (" << Edges[low].f << ", " << Edges[low].s << ")\n";
      |                               ^
highway.cpp:42:55: error: invalid types 'int[int]' for array subscript
   42 |     cout << "Found (" << Edges[low].f << ", " << Edges[low].s << ")\n";
      |                                                       ^
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:54:15: error: request for member 'push_back' in 'Edges', which is of non-class type 'int'
   54 |         Edges.push_back({u[i], v[i]});
      |               ^~~~~~~~~
highway.cpp:60:5: error: reference to 'distance' is ambiguous
   60 |     distance = ask(w) / A;
      |     ^~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from highway.h:3,
                 from highway.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:138:5: note: candidates are: 'template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  138 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
highway.cpp:6:5: note:                 'int distance'
    6 | int distance;
      |     ^~~~~~~~
highway.cpp:60:20: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'int [M]'
   60 |     distance = ask(w) / A;
      |                    ^
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^