# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
926883 |
2024-02-14T03:48:14 Z |
irmuun |
Swap (BOI16_swap) |
C++17 |
|
1 ms |
348 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n;
cin>>n;
vector<ll>a(n+1);
a[0]=0;
for(ll i=1;i<=n;i++){
cin>>a[i];
}
vector<ll>ans(n+1,1e18);
for(ll j=0;j<(1<<(n/2));j++){
ll cur=j;
vector<ll>b=a;
for(ll i=1;i<=n;i++){
ll x=i*2,y=i*2+1;
if(x>n) continue;
if(x==n){
if(b[i]>b[x]) swap(b[i],b[x]);
}
else{
ll c[3];
c[0]=b[i];
c[1]=b[x];
c[2]=b[y];
sort(c,c+3);
if(cur&1){
b[i]=c[0];
b[x]=c[1];
b[y]=c[2];
}
else{
b[i]=c[0];
b[x]=c[2];
b[y]=c[1];
}
cur=cur>>1;
}
}
ans=min(ans,b);
}
for(ll i=1;i<=n;i++){
cout<<ans[i]<<' ';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |