#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int LLI;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
#include "swaps.h"
int used[500];
void solve(int N,int V) {
int i,j;
vi order;
for (i = 0; i < N; i++) order.pb(i+1);
int s = sqrt(N);
for (j = 0; j < s; j++) {
vi v1,v2;
for (i = s; i < N; i++) {
if (!used[i-s]) v1.pb(i),schedule(order[i-s],order[i]),used[i-s] = used[i] = 1;
else v2.pb(i);
}
fill(used,used+N,0);
vi r = visit();
for (i = 0; i < r.size(); i++) {
if (!r[i]) swap(order[v1[i]-s],order[v1[i]]);
}
for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-s],order[v2[i]]);
r = visit();
for (i = 0; i < r.size(); i++) {
if (!r[i]) swap(order[v2[i]-s],order[v2[i]]);
}
}
for (j = 0; j < 2*s; j++) {
vi v1,v2;
for (i = 1; i < N; i++) {
if (i & 1) schedule(order[i-1],order[i]),v1.pb(i);
else v2.pb(i);
}
vi r = visit();
for (i = 0; i < r.size(); i++) {
if (!r[i]) swap(order[v1[i]-1],order[v1[i]]);
}
for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-1],order[v2[i]]);
r = visit();
for (i = 0; i < r.size(); i++) {
if (!r[i]) swap(order[v2[i]-1],order[v2[i]]);
}
}
answer(order);
}
Compilation message
swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (i = 0; i < r.size(); i++) {
| ~~^~~~~~~~~~
swaps.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-s],order[v2[i]]);
| ~~^~~~~~~~~~~
swaps.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for (i = 0; i < r.size(); i++) {
| ~~^~~~~~~~~~
swaps.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (i = 0; i < r.size(); i++) {
| ~~^~~~~~~~~~
swaps.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-1],order[v2[i]]);
| ~~^~~~~~~~~~~
swaps.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for (i = 0; i < r.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
3 ms |
296 KB |
Correct |
3 |
Incorrect |
8 ms |
200 KB |
Not correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
3 ms |
200 KB |
Correct |
3 |
Incorrect |
6 ms |
276 KB |
Not correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
3 ms |
200 KB |
Not correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
3 ms |
200 KB |
Not correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
3 ms |
200 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
3 ms |
200 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
2 ms |
200 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
2 ms |
200 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
3 ms |
296 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
3 ms |
296 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
3 ms |
200 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Incorrect |
3 ms |
200 KB |
Not correct |
3 |
Halted |
0 ms |
0 KB |
- |