#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define pb push_back
#define F first
#define S second
#define len(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define file freopen("txt.in", "r", stdin);freopen("txt.out", "w", stdout);
#define kill(x) {cout << x << '\n'; return 0;}
#define int long long
const int maxn = 1e5 + 5, LG = 21, MOD = 1e9+7;// 998244353
const ll inf = 1061109567;
int n, a[LG];
string cur, tmp, s;
inline void solve() {
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> a[i];
cur.pb(a[i] + 48);
}
s = cur;
for(int i = 0; i < (1<<(n-1)); ++i) {
tmp = s;
for(int j = 0; j < n-1; ++j) {
if((1<<j) & i) {
swap(tmp[j+1], tmp[(j+2)/2-1]);
}
}
if(tmp < cur) cur = tmp;
tmp = s;
}
for(int i = 0; i < len(cur); ++i){
cout << cur[i] << ' ';
}
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |