#include <bits/stdc++.h>
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define fast_io ios::sync_with_stdio(false);cin.tie(0);
#define what(x) cerr << #x << " is " << x << '\n';
#define kill(x) {cout << x << '\n'; return 0;}
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define pb push_back
#define ll long long
#define F first
#define S second
const ll inf = 1e18, mod = 1e9 + 7, delta = 1e9 + 9, SQ = 450, P = 6065621;
using namespace std;
const ll N = 1e5 + 10, LG = 22;
int a[N], ans[N], b[N];
int main() {
fast_io;
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[i] = a[i];
ans[i] = a[i];
}
for (int mask = 1; mask < (1 << n); mask++) {
for (int i = 1; i <= n; i++) a[i] = b[i];
for (int i = 1; i < n; i++) {
if (mask & (1 << i))
swap(a[i + 1], a[(i + 1) / 2]);
}
int pt = 1;
while (pt <= n && a[pt] == ans[pt]) pt++;
if (pt == n + 1) continue;
if (a[pt] < ans[pt]) {
for (int i = 1; i <= n; i++)
ans[i] = a[i];
}
}
for (int i = 1; i <= n; i++)
cout << ans[i] << ' ';
cout << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
440 KB |
Output is correct |
2 |
Correct |
65 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
444 KB |
Output is correct |
4 |
Correct |
69 ms |
348 KB |
Output is correct |
5 |
Correct |
65 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
440 KB |
Output is correct |
2 |
Correct |
65 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
444 KB |
Output is correct |
4 |
Correct |
69 ms |
348 KB |
Output is correct |
5 |
Correct |
65 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
440 KB |
Output is correct |
2 |
Correct |
65 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
444 KB |
Output is correct |
4 |
Correct |
69 ms |
348 KB |
Output is correct |
5 |
Correct |
65 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
440 KB |
Output is correct |
2 |
Correct |
65 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
444 KB |
Output is correct |
4 |
Correct |
69 ms |
348 KB |
Output is correct |
5 |
Correct |
65 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
440 KB |
Output is correct |
2 |
Correct |
65 ms |
348 KB |
Output is correct |
3 |
Correct |
69 ms |
444 KB |
Output is correct |
4 |
Correct |
69 ms |
348 KB |
Output is correct |
5 |
Correct |
65 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |