# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1007451 | kebine | Art Collections (BOI22_art) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}