# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
725007 | FatihSolak | Art Collections (BOI22_art) | C++17 | 1572 ms | 692 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;
int n;
bool cmp(int a,int b){
vector<int> ask1 = {a,b};
vector<int> ask2 = {b,a};
for(int i = 1;i<=n;i++){
if(i != a && i != b){
ask1.push_back(i);
ask2.push_back(i);
}
}
if(publish(ask1) > publish(ask2)){
return 1;
}
return 0;
}
vector<int> srt(vector<int> v){
if(v.size() == 1){
return v;
}
vector<int> a;
vector<int> b;
int asz = v.size()/2;
int bsz = v.size()-asz;
for(int i = 0;i<asz;i++){
a.push_back(v[i]);
}
for(int i = asz;i<asz+bsz;i++){
b.push_back(v[i]);
}
a = srt(a);
b = srt(b);
vector<int> ret;
int pt1 = 0;
for(int i = 0;i<asz;){
if(pt1 < bsz && cmp(a[i],b[pt1])){
ret.push_back(b[pt1]);
pt1++;
}
else{
ret.push_back(a[i]);
i++;
}
}
while(pt1 <bsz){
ret.push_back(b[pt1]);
pt1++;
}
return ret;
}
void solve(int N) {
n = N;
vector<int> order;
vector<int> pos(N+1);
for(int i = 1;i<=N;i++){
order.push_back(i);
}
//order = srt(order);
int last = publish(order);
for(int i = 1;i<n;i++){
vector<int> nw;
for(int i = 1;i<n;i++)
nw.push_back(order[i]);
nw.push_back(order[0]);
order = nw;
int now = publish(order);
int delta = now - last;
//cout << last << " " << now << endl;
pos[i] = (delta - n - 1)/-2;
last = now;
}
vector<int> ans(N+1,N);
for(int i = 1;i<n;i++){
ans[pos[i]] = i;
}
order.clear();
for(int i = 1;i<=N;i++){
order.push_back(ans[i]);
}
answer(order);
}
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... |