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 <chrono>
#include <random>
using namespace std;
#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>
typedef long long ll;
const ll mxN=2e5+5;
ll n;
ll a[mxN];
void solve(){
vll tep(n);
for(ll i=1;i<=n;i++){
tep[i-1]=a[i];
}
vector<vll> ans;
for(ll mask=0;mask<(1LL<<n);mask++){
if(mask&1) continue;
vll tep2=tep;
for(ll j=1;j<n;j++){
if(mask&(1LL<<j)){
swap(tep2[(j+1)/2-1], tep2[j]);
}
}
ans.pb(tep2);
}
sort(ans.begin(), ans.end());
for(auto &it:ans[0]){
cout<<it<<' ';
}
cout<<'\n';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
cin>>n;
for(ll i=1;i<=n;i++){
cin>>a[i];
}
solve();
return 0;
}
# | 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... |