# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580181 | penguinhacker | Art Collections (BOI22_art) | C++17 | 1748 ms | 728 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 <bits/stdc++.h>
#include "art.h"
using namespace std;
#define ll long long
#define ar array
void solve(int n) {
vector<int> a(n), ans(n, -1);
iota(a.begin(), a.end(), 1);
int last=publish(a);
for (int i=1; i<=n-1; ++i) {
a.erase(a.begin());
a.insert(a.begin()+n-i, i);
int cur=publish(a);
int bigger=(last-cur)+(n-i); // how many elements is p_i greater than {p_i+1, p_i+2, ... , p_n}
assert(bigger%2==0);
bigger/=2;
for (int j=0; j<n; ++j) {
if (ans[j]!=-1)
continue;
if (bigger==0) {
ans[j]=i;
break;
}
--bigger;
}
last=cur;
}
for (int i=0; i<n; ++i)
if (ans[i]==-1)
ans[i]=n;
answer(ans);
}
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... |