#include <bits/stdc++.h>
#include "swaps.h"
using namespace std;
typedef pair<int, int> pii;
#define MAX 101010
int ans[MAX];
vector<pii> qv[MAX];
void simulate(int V) {
int i;
for (i = 1; i <= V; i++) {
if (qv[i].empty()) continue;
for (auto& [a, b] : qv[i]) schedule(ans[a], ans[b]);
auto res = visit();
int p = 0;
for (auto& [a, b] : qv[i]) if (!res[p++]) swap(ans[a], ans[b]);
}
}
void solve(int N, int V) {
int i;
for (i = 1; i <= N; i++) ans[i] = i;
int K = 9;
int cnt = 0;
int T = 0;
for (T = 0; T < 10; T++) {
for (int k = 0; k < K; k++) {
int d = 1 << k;
cnt++;
for (i = 1; i <= N; i++) if (i >> k & 1 && (i - d) > 0) qv[cnt].emplace_back(i - d, i);
cnt++;
for (i = 1; i <= N; i++) if (!(i >> k & 1) && (i - d) > 0) qv[cnt].emplace_back(i - d, i);
}
for (int k = K - 1; k >= 0; k--) {
int d = 1 << k;
cnt++;
for (i = 1; i <= N; i++) if (i >> k & 1 && (i - d) > 0) qv[cnt].emplace_back(i - d, i);
cnt++;
for (i = 1; i <= N; i++) if (!(i >> k & 1) && (i - d) > 0) qv[cnt].emplace_back(i - d, i);
}
}
simulate(N);
vector<int> ansv;
for (i = 1; i <= N; i++) ansv.push_back(ans[i]);
answer(ansv);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |