# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
926892 |
2024-02-14T03:56:11 Z |
irmuun |
Swap (BOI16_swap) |
C++17 |
|
1000 ms |
604 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(b[i]==c[0]) continue;
if(b[x]==c[0]){
swap(b[x],b[i]);
}
else{
if(cur&1){
swap(b[i],b[x]);
}
swap(b[i],b[y]);
cur=cur>>1;
}
}
}
ans=min(ans,b);
}
for(ll i=1;i<=n;i++){
cout<<ans[i]<<' ';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
452 KB |
Output is correct |
6 |
Correct |
324 ms |
348 KB |
Output is correct |
7 |
Correct |
341 ms |
348 KB |
Output is correct |
8 |
Correct |
329 ms |
348 KB |
Output is correct |
9 |
Correct |
336 ms |
432 KB |
Output is correct |
10 |
Correct |
343 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
452 KB |
Output is correct |
6 |
Correct |
324 ms |
348 KB |
Output is correct |
7 |
Correct |
341 ms |
348 KB |
Output is correct |
8 |
Correct |
329 ms |
348 KB |
Output is correct |
9 |
Correct |
336 ms |
432 KB |
Output is correct |
10 |
Correct |
343 ms |
432 KB |
Output is correct |
11 |
Execution timed out |
1066 ms |
348 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
452 KB |
Output is correct |
6 |
Correct |
324 ms |
348 KB |
Output is correct |
7 |
Correct |
341 ms |
348 KB |
Output is correct |
8 |
Correct |
329 ms |
348 KB |
Output is correct |
9 |
Correct |
336 ms |
432 KB |
Output is correct |
10 |
Correct |
343 ms |
432 KB |
Output is correct |
11 |
Execution timed out |
1066 ms |
348 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
452 KB |
Output is correct |
6 |
Correct |
324 ms |
348 KB |
Output is correct |
7 |
Correct |
341 ms |
348 KB |
Output is correct |
8 |
Correct |
329 ms |
348 KB |
Output is correct |
9 |
Correct |
336 ms |
432 KB |
Output is correct |
10 |
Correct |
343 ms |
432 KB |
Output is correct |
11 |
Execution timed out |
1066 ms |
348 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |