Submission #721581

#TimeUsernameProblemLanguageResultExecution timeMemory
721581sunnatArt Collections (BOI22_art)C++17
Compilation error
0 ms0 KiB
#include "art.h" #include <iostream> using namespace std; int start_inv, x; vector<int> order; void merge_sort(int l, int r){ if(l >= r-1) return; int m = (l + r) / 2; merge_sort(l, m); merge_sort(m, r); int n = r - l; vector<int>b(n); start_inv = publish(order); for(int i = 0, u = l, v = m; i < n; i ++){ if(u == m) b[i] = order[v ++]; else if(v == r) b[i] = order[u ++]; else{ swap(order[u], order[v]); x = publish(order); swap(order[u], order[v]); if(x < start_inv) b[i] = order[v ++]; else b[i] = order[u ++]; } } for(int i = 0; i < n; i ++) order[i+l] = b[i]; } void solve(int N) { for(int i = 1; i <= n; i ++) order.push_back(i); merge_sort(0, N); answer(order); }

Compilation message (stderr)

art.cpp: In function 'void solve(int)':
art.cpp:31:25: error: 'n' was not declared in this scope
   31 |     for(int i = 1; i <= n; i ++) order.push_back(i);
      |                         ^
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) {
      |        ~~~~~~~~~^~~~