# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
597756 | yanndev | Art Collections (BOI22_art) | C++17 | 1477 ms | 764 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;
vector<int> graph[4042];
void solve(int n) {
vector<int> posOfVal(n, -1);
for (int i = 1; i <= n; i++) {
vector<int> ls {};
ls.push_back(i);
for (int j = 1; j <= n; j++)
if (j != i)
ls.push_back(j);
int oldInv = publish(ls);
ls.clear();
for (int j = 1; j <= n; j++)
if (j != i)
ls.push_back(j);
ls.push_back(i);
int curInv = publish(ls);
// curInv= oldInv - (rank - 1) + (n - rank)
// curInv = oldInv - (2 * rank) + (n - 1)
// -(curInv - oldInv - (n - 1))/2 = rank
posOfVal[i] = -(curInv - oldInv - (n - 1)) / 2;
}
vector<int> ls (n, -1);
for (int i = 1; i <= n; i++)
ls[posOfVal[i]] = i;
answer(ls);
}
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... |