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>
using namespace std;
const int N = 21;
int v[N];
int at[N];
int res[N];
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> v[i];
res[i] = v[i];
}
for(int mask = 0;mask < (1<<n);mask++){
for(int j = 1;j <= n;j++){
at[j] = v[j];
if(j == 1) continue;
if((1<<(j-1))&mask){
swap(at[j], at[j/2]);
}
}
for(int j = 1;j <= n;j++){
if(at[j] < res[j]){
for(int j = 1;j <= n;j++){
res[j] = at[j];
}
break;
}
if(at[j] > res[j]) break;
}
}
for(int i = 1;i <= n;i++){
cout << res[i] << ' ';
}
cout<< '\n';
}
# | 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... |