Submission #597755

# Submission time Handle Problem Language Result Execution time Memory
597755 2022-07-16T19:41:24 Z yanndev Art Collections (BOI22_art) C++17
Compilation error
0 ms 0 KB
#include <art.h>
#include <bits/stdc++.h>

vector<int> graph[4042];

void solve(int n) {
    vector<int> posOfVal(n, -1);

    for (int i = 1; i <= n; i++) {
        vector<int> ls {};
        ls.push_back(i);
        for (int j = 1; j <= n; j++)
            if (j != i)
                ls.push_back(j);

        int oldInv = publish(ls);
        
        ls.clear();
        for (int j = 1; j <= n; j++)
            if (j != i)
                ls.push_back(j);
        ls.push_back(i);

        int curInv = publish(ls);
        // curInv= oldInv - (rank - 1) + (n - rank)
        // curInv = oldInv - (2 * rank) + (n - 1)
        // -(curInv - oldInv - (n - 1))/2 = rank
        posOfVal[i] = -(curInv - oldInv - (n - 1)) / 2;
    }

    vector<int> ls (n, -1);
    for (int i = 1; i <= n; i++)
        ls[posOfVal[i]] = i;
    answer(ls);
}

Compilation message

art.cpp:4:1: error: 'vector' does not name a type
    4 | vector<int> graph[4042];
      | ^~~~~~
art.cpp: In function 'void solve(int)':
art.cpp:7:5: error: 'vector' was not declared in this scope
    7 |     vector<int> posOfVal(n, -1);
      |     ^~~~~~
art.cpp:7: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:7:12: error: expected primary-expression before 'int'
    7 |     vector<int> posOfVal(n, -1);
      |            ^~~
art.cpp:10:16: error: expected primary-expression before 'int'
   10 |         vector<int> ls {};
      |                ^~~
art.cpp:11:9: error: 'ls' was not declared in this scope
   11 |         ls.push_back(i);
      |         ^~
art.cpp:28:9: error: 'posOfVal' was not declared in this scope
   28 |         posOfVal[i] = -(curInv - oldInv - (n - 1)) / 2;
      |         ^~~~~~~~
art.cpp:31:12: error: expected primary-expression before 'int'
   31 |     vector<int> ls (n, -1);
      |            ^~~
art.cpp:33:9: error: 'ls' was not declared in this scope
   33 |         ls[posOfVal[i]] = i;
      |         ^~
art.cpp:33:12: error: 'posOfVal' was not declared in this scope
   33 |         ls[posOfVal[i]] = i;
      |            ^~~~~~~~
art.cpp:34:12: error: 'ls' was not declared in this scope
   34 |     answer(ls);
      |            ^~
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) {
      |        ~~~~~~~~~^~~~