| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 598060 | jhnah917 | Art Collections (BOI22_art) | C++17 | 771 ms | 536 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.
#ifndef LOCAL
#include "art.h"
#endif
#include <bits/stdc++.h>
using namespace std;
int inv;
vector<int> tv;
bool compare(int a, int b){
if(a == b) return false;
swap(tv[a-1], tv[b-1]);
int t = publish(tv);
swap(tv[a-1], tv[b-1]);
if(a < b) return inv < t;
return inv > t;
}
void merge_sort(vector<int> &ord, int s, int e){
if(s >= e) return;
int m = (s + e) / 2;
merge_sort(ord, s, m);
merge_sort(ord, m+1, e);
vector<int> tmp(ord.size());
int i = s, j = m+1, k = s;
while(i <= m && j <= e){
if(compare(ord[i], ord[j])) tmp[k++] = ord[i++];
else tmp[k++] = ord[j++];
}
while(i <= m) tmp[k++] = ord[i++];
while(j <= e) tmp[k++] = ord[j++];
for(k=s; k<=e; k++) ord[k] = tmp[k];
}
void solve(int n){
tv.resize(n);
iota(tv.begin(), tv.end(), 1);
auto ord = tv;
inv = publish(tv);
merge_sort(ord, 0, n-1);
answer(ord);
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
