#include <bits/stdc++.h>
using namespace std;
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define Add(x,y) x=(x+y)%mod
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
const int N=1e6+99;
int n,t,a[N],b[N],ans[N];
int main(){
fill(ans,ans+N,N);
cin>>n;
f(i,1,n+1) cin>>a[i];
f(mask,0,(1<<n-1)){
f(i,1,n+1){
b[i]=a[i];
}
f(i,0,n-1){
if(mask&(1<<i)){
swap(b[i+2],b[(i+2)/2]);
}
}
f(i,1,n+1){
if(b[i]>ans[i]) break;
if(b[i]<ans[i]){
f(i,1,n+1) ans[i]=b[i];
break;
}
}
}
f(i,1,n+1) cout<<ans[i]<<" ";
}
Compilation message
swap.cpp: In function 'int main()':
swap.cpp:28:16: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
28 | f(mask,0,(1<<n-1)){
| ~^~
swap.cpp:7:32: note: in definition of macro 'f'
7 | #define f(i,a,b) for(int i=a;i<b;i++)
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
4172 KB |
Output is correct |
2 |
Correct |
37 ms |
4200 KB |
Output is correct |
3 |
Correct |
42 ms |
4204 KB |
Output is correct |
4 |
Correct |
40 ms |
4208 KB |
Output is correct |
5 |
Correct |
36 ms |
4172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
4172 KB |
Output is correct |
2 |
Correct |
37 ms |
4200 KB |
Output is correct |
3 |
Correct |
42 ms |
4204 KB |
Output is correct |
4 |
Correct |
40 ms |
4208 KB |
Output is correct |
5 |
Correct |
36 ms |
4172 KB |
Output is correct |
6 |
Incorrect |
3 ms |
4172 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
4172 KB |
Output is correct |
2 |
Correct |
37 ms |
4200 KB |
Output is correct |
3 |
Correct |
42 ms |
4204 KB |
Output is correct |
4 |
Correct |
40 ms |
4208 KB |
Output is correct |
5 |
Correct |
36 ms |
4172 KB |
Output is correct |
6 |
Incorrect |
3 ms |
4172 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
4172 KB |
Output is correct |
2 |
Correct |
37 ms |
4200 KB |
Output is correct |
3 |
Correct |
42 ms |
4204 KB |
Output is correct |
4 |
Correct |
40 ms |
4208 KB |
Output is correct |
5 |
Correct |
36 ms |
4172 KB |
Output is correct |
6 |
Incorrect |
3 ms |
4172 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
4172 KB |
Output is correct |
2 |
Correct |
37 ms |
4200 KB |
Output is correct |
3 |
Correct |
42 ms |
4204 KB |
Output is correct |
4 |
Correct |
40 ms |
4208 KB |
Output is correct |
5 |
Correct |
36 ms |
4172 KB |
Output is correct |
6 |
Incorrect |
3 ms |
4172 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |