# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
721581 | sunnat | Art Collections (BOI22_art) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}