# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1007451 | kebine | 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 <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
// int publish(vector<int> B) {
// answer(B);
// int ans;cin>>ans;
// return ans;
// }
// void answer(vector<int> B) {
// for (auto el : B) cout << el << " ";
// cout << endl;
// }
// A = [5, 2, 3, 1, 4], inv = 4 + 1 + 1 = 6
// A = [2, 3, 1, 4, 5], inv = 1 + 1 = 2
// A = [3, 1, 4, 5, 2], inv = 2 + 1 + 1 = 4
// A = [1, 4, 5, 2, 3], inv = 2+2 = 4
// A = [4, 5, 2, 3, 1], inv = 3+3+2 = 8
void solve(int n) {
vector<int> a(n);
iota(all(a),1);
vector<int> rec(n);
vector<int> ans;
for (int i = 0; i < n; i++) {
int x = publish(a);
a.push_back(*a.begin());
a.erase(a.begin());
ans.push_back(x);
}
vector<pair<int, int>> delt(n);
for (int i = 0; i < n; i++) {
delt[i] = {ans[(i+1)%n] - ans[i], i};
}
sort(all(delt));
reverse(all(delt));
for (int i = 0; i < n; i++) rec[i] = delt[i].second+1;
answer(rec);
}
int main() {
int n;cin>>n;
solve(n);
}