| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1000046 | pcc | Art Collections (BOI22_art) | C++17 | 1104 ms | 1824 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"
//
// --- Sample implementation for the task art ---
//
// To compile this program with the sample grader, place:
// art.h art_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
// g++ -std=c++17 art_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
/*
std::vector<int> order = {1, 2, 3};
publish(order);
order = {2, 3, 1};
publish(order);
order = {1, 3, 2};
answer(order);
*/
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
ordered_set<int> big,small;
vector<int> apply_perm(vector<int> v){
auto re = v;
for(int i = 0;i<v.size();i++){
re[v[i]-1] = i+1;
}
return re;
}
void solve(int N) {
vector<int> v;
for(int i = 1;i<=N;i++)v.push_back(i);
vector<int> dif(N,0);
for(int i = 0;i<N;i++){
swap(v[i],v[0]);
dif[i] = publish(v);
swap(v[i],v[0]);
}
for(auto &i:dif)cerr<<i<<' ';cerr<<endl;
vector<int> ans(N,0);
for(int i = 1;i<N;i++)big.insert(i),small.insert(i);
for(int i = N-1;i>0;i--){
int d = dif[i]-dif[0];
assert(abs(d)%2==1);
if(d>0)d++;
else d--;
d/=2;
if(d>0){
auto it = big.find_by_order(d-1);
ans[i] = *it;
big.erase(*it);
}
else{
auto it = small.find_by_order(-d-1);
ans[i] = -*it;
small.erase(*it);
}
}
int mn = 0;
for(auto &i:ans)mn = min(mn,i);
for(auto &i:ans)i = (i-mn+1);
ans = apply_perm(ans);
answer(ans);
}
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... | ||||
