# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
735166 | DAleksa | 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"
void solve(int n) {
vector<int> inv(n);
vector<int> ask(n);
iota(ask.begin(), ask.end(), 1);
inv[0] = publish(ask);
for(int i = 1; i < n; i++) {
ask[n - 1] = i;
for(int j = 0; j < n - 1; j++) ask[j] = (j + 1 < i ? j + 1 : j + 2);
inv[i] = publish(ask);
}
for(int i = 0; i < n; i++) cout << inv[i] << " ";
cout << "\n";
for(int i = 1; i < n; i++) inv[i] = (inv[0] - inv[i] + n - i) / 2;
vector<int> res(n);
vector<bool> mark(n + 1, false);
for(int i = 1; i < n; i++) {
int cnt = 0;
for(int j = 1; j <= n; j++) {
if(mark[j]) continue;
cnt++;
if(cnt == inv[i] + 1) {
res[i - 1] = i;
mark[i] = true;
}
}
}
for(int i = 1; i <= n; i++) {
if(!mark[i]) {
res[n - 1] = i;
break;
}
}
answer(res);
}
// inv[0] - inv[1] = < - >
// < + > = n - 1
// inv[0] - inv[1] + n - 1 = 2 * <
//