Submission #735166

# Submission time Handle Problem Language Result Execution time Memory
735166 2023-05-03T16:28:19 Z DAleksa Art Collections (BOI22_art) C++17
Compilation error
0 ms 0 KB
#include "art.h"

void solve(int n) {
    vector<int> inv(n);
    vector<int> ask(n);
    iota(ask.begin(), ask.end(), 1);
    inv[0] = publish(ask);
    for(int i = 1; i < n; i++) {
        ask[n - 1] = i;
        for(int j = 0; j < n - 1; j++) ask[j] = (j + 1 < i ? j + 1 : j + 2);
        inv[i] = publish(ask);
    }
    for(int i = 0; i < n; i++) cout << inv[i] << " ";
    cout << "\n";
    for(int i = 1; i < n; i++) inv[i] = (inv[0] - inv[i] + n - i) / 2;
    vector<int> res(n);
    vector<bool> mark(n + 1, false);
    for(int i = 1; i < n; i++) {
        int cnt = 0;
        for(int j = 1; j <= n; j++) {
            if(mark[j]) continue;
            cnt++;
            if(cnt == inv[i] + 1) {
                res[i - 1] = i;
                mark[i] = true;
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        if(!mark[i]) {
            res[n - 1] = i;
            break;
        }
    }
    answer(res);
}
// inv[0] - inv[1] = < - >
// < + > = n - 1
// inv[0] - inv[1] + n - 1 = 2 * <
//

Compilation message

art.cpp: In function 'void solve(int)':
art.cpp:4:5: error: 'vector' was not declared in this scope
    4 |     vector<int> inv(n);
      |     ^~~~~~
art.cpp:4:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from art.h:1,
                 from art.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from art.h:1,
                 from art.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
art.cpp:4:12: error: expected primary-expression before 'int'
    4 |     vector<int> inv(n);
      |            ^~~
art.cpp:5:12: error: expected primary-expression before 'int'
    5 |     vector<int> ask(n);
      |            ^~~
art.cpp:6:10: error: 'ask' was not declared in this scope
    6 |     iota(ask.begin(), ask.end(), 1);
      |          ^~~
art.cpp:6:5: error: 'iota' was not declared in this scope
    6 |     iota(ask.begin(), ask.end(), 1);
      |     ^~~~
art.cpp:7:5: error: 'inv' was not declared in this scope; did you mean 'int'?
    7 |     inv[0] = publish(ask);
      |     ^~~
      |     int
art.cpp:13:32: error: 'cout' was not declared in this scope
   13 |     for(int i = 0; i < n; i++) cout << inv[i] << " ";
      |                                ^~~~
art.cpp:14:5: error: 'cout' was not declared in this scope
   14 |     cout << "\n";
      |     ^~~~
art.cpp:16:12: error: expected primary-expression before 'int'
   16 |     vector<int> res(n);
      |            ^~~
art.cpp:17:12: error: expected primary-expression before 'bool'
   17 |     vector<bool> mark(n + 1, false);
      |            ^~~~
art.cpp:21:16: error: 'mark' was not declared in this scope
   21 |             if(mark[j]) continue;
      |                ^~~~
art.cpp:24:17: error: 'res' was not declared in this scope
   24 |                 res[i - 1] = i;
      |                 ^~~
art.cpp:25:17: error: 'mark' was not declared in this scope
   25 |                 mark[i] = true;
      |                 ^~~~
art.cpp:30:13: error: 'mark' was not declared in this scope
   30 |         if(!mark[i]) {
      |             ^~~~
art.cpp:31:13: error: 'res' was not declared in this scope
   31 |             res[n - 1] = i;
      |             ^~~
art.cpp:35:12: error: 'res' was not declared in this scope
   35 |     answer(res);
      |            ^~~
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~