//
// --- 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 <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using pi = pair<int,int>;
void solve(int N, int V) {
vector<vector<int>> lw(N,vector<int>(N,-1));
for(int st = 0; st < N; st ++) {
vector<int> res;
int idx;
vector<pi> ss;
for(int l = 0; l < N/2; l ++) {
int i = (st + l)%N;
int j = (st + N - 1 - l)%N;
if(i > j) { swap(i,j); }
ss.push_back({i,j});
}
for(pi p : ss) {
schedule(p.f+1,p.s+1);
}
res = visit();
idx = 0;
for(pi p : ss) {
lw[p.f][p.s] = res[idx];
lw[p.f][p.s] = 1 - res[idx];
idx ++;
}
ss.clear();
for(int l = 0; l < (N-1)/2; l ++) {
int i = (st + l)%N;
int j = (st + N - 2 - l)%N;
if(i > j) { swap(i,j); }
ss.push_back({i,j});
}
for(pi p : ss) {
schedule(p.f+1,p.s+1);
}
res = visit();
idx = 0;
for(pi p : ss) {
lw[p.f][p.s] = res[idx];
lw[p.f][p.s] = 1 - res[idx];
idx ++;
}
}
vector<int> res(N);
for(int i = 0; i < N; i ++) {
res[i] = i;
}
// for(int it = 0; it < 2*N; it ++) {
// for(int i = 1; i < N; i ++) {
// if(lw[res[i-1]][res[i]]) {
// swap(res[i-1],res[i]);
// }
// }
// }
for(int &r : res) { r ++; }
answer(res);
}
/*
g++ swaps.cpp grader.cpp -o g.exe && g.exe
5 1000
2 1 5 3 4
*/
# |
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 |
Incorrect |
1 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 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 |
Incorrect |
1 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 |
Incorrect |
1 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 |
Incorrect |
1 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 |
Incorrect |
1 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |