이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |