# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120606 | vjudge1 | Art Collections (BOI22_art) | C++17 | 1 ms | 336 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<bits/stdc++.h>
#include "art.h"
using namespace std;
int u[4001];
int p[4001];
int pp[4001];
int nn;
int a[4001];
// int publish(vector<int>r){
// int j=0;
// for(int i=0;i<nn;i++){
// //cout<<r[i]<<" ";
// if(p[r[i]]<i){
// j+=i-p[r[i]];
// }
// }
// //cout<<" "<<j;
// //cout<<"\n";
// return j;
// }
// void answer(vector<int>r){
// for(int i=0;i<nn;i++){
// cout<<r[i]<<" ";
// }
// cout<<"\n";
// }
vector<int> get(vector<int>v,int uu,int d,int p){
vector<int>ans;
//cout<<uu<<" "<<d<<" "<<p<<"\n";
for(int i=0;i<nn;i++){
if(i==uu){
continue;
}
if(i==p){
ans.push_back(d);
}
ans.push_back(v[i]);
}
return ans;
}
void solve (int n){
vector<int>v;
for(int i=1;i<=n;i++){
v.push_back(i);
}
int k=publish(v);
if(k==0){
answer(v);
return;
}
while(publish(v)!=0){
for(int i=0;i<n;i++){
u[i]=0;
}
for(int i=n-1;i>=0;i--){
//cout<<"\n\n";
if(u[i]==0){
//cout<<v[i]<<"\n\n";
k=publish(v);
if(k==0){
answer(v);
return;
}
int x;
int j=i;
for(int l=j-1;l>=0;l--){
if(u[l]==0){
vector<int>s=get(v,j,v[j],l);
x=publish(s);
if(x==0){
answer(s);
return;
}
if(x<k){
k=x;
j=l;
v=s;
}
}
}
//cout<<j<<"\n\n";
u[j]=1;
i++;
}
}
}
// for(int i=0;i<n;i++){
// cout<<u[i]<<" ";
// }
// cout<<"\n";
answer(v);
}
// int main(){
// cin>>nn;
// for(int i=0;i<nn;i++){
// cin>>a[i];
// p[a[i]]=i;
// }
// solve(nn);
// }
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... |