//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
// swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include "swaps.h"
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define pb push_back
void solve(int N, int V) {
vector<int> P, x, y;
set<int> ss;
for (int i = 1; i <= N; i++) {
P.pb(i);
}
for (int p = 1; p < N; p <<= 1) {
for (int k = p; k >= 1; k >>= 1) {
for (int j = k % p; j <= N - 1 - k; j += (k << 1)) {
for (int i = 0; i <= min(k - 1, N - j - k - 1); i++) {
if ((i + j) / (p << 1) == (i + j + k) / (p << 1)) {
if (ss.find(i + j + 1) != ss.end() || ss.find(i + j + k + 1) != ss.end()) {
auto ret = visit();
for (int l = 0; l < (int)ret.size(); l++) {
if (!ret[l]) swap(P[x[l]], P[y[l]]);
}
x.clear();
y.clear();
ss.clear();
}
x.pb(i + j);
y.pb(i + j + k);
ss.insert(i + j + 1);
ss.insert(i + j + k + 1);
schedule(i + j + 1, i + j + k + 1);
}
}
}
}
}
auto ret = visit();
for (int l = 0; l < (int)ret.size(); l++) {
if (!ret[l]) swap(P[x[l]], P[y[l]]);
}
answer(P);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
3 |
Incorrect |
1 ms |
280 KB |
Not correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
3 |
Correct |
3 ms |
320 KB |
Correct |
4 |
Correct |
4 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
3 |
Correct |
3 ms |
320 KB |
Correct |
4 |
Correct |
4 ms |
344 KB |
Correct |
5 |
Incorrect |
1 ms |
208 KB |
Not correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
3 |
Correct |
2 ms |
208 KB |
Correct |
4 |
Correct |
4 ms |
332 KB |
Correct |
5 |
Correct |
6 ms |
320 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
3 |
Correct |
2 ms |
208 KB |
Correct |
4 |
Correct |
4 ms |
332 KB |
Correct |
5 |
Correct |
6 ms |
320 KB |
Correct |
6 |
Incorrect |
0 ms |
208 KB |
Not correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
3 |
Correct |
2 ms |
208 KB |
Correct |
4 |
Correct |
4 ms |
332 KB |
Correct |
5 |
Correct |
6 ms |
288 KB |
Correct |
6 |
Correct |
5 ms |
288 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
3 |
Correct |
2 ms |
208 KB |
Correct |
4 |
Correct |
4 ms |
332 KB |
Correct |
5 |
Correct |
6 ms |
288 KB |
Correct |
6 |
Correct |
5 ms |
288 KB |
Correct |
7 |
Incorrect |
1 ms |
304 KB |
Not correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
3 |
Correct |
2 ms |
208 KB |
Correct |
4 |
Correct |
5 ms |
336 KB |
Correct |
5 |
Correct |
4 ms |
316 KB |
Correct |
6 |
Correct |
4 ms |
280 KB |
Correct |
7 |
Correct |
6 ms |
268 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
1 ms |
208 KB |
Correct |
3 |
Correct |
2 ms |
208 KB |
Correct |
4 |
Correct |
5 ms |
336 KB |
Correct |
5 |
Correct |
4 ms |
316 KB |
Correct |
6 |
Correct |
4 ms |
280 KB |
Correct |
7 |
Correct |
6 ms |
268 KB |
Correct |
8 |
Incorrect |
1 ms |
208 KB |
Not correct |
9 |
Halted |
0 ms |
0 KB |
- |