#include <bits/stdc++.h>
using namespace std;
#include "swaps.h"
int a[2001] = {0};
int n , xd;
int x = 0;
void compp(int a,int b){
if(b<=n&&a<=n){
schedule(a,b);
x++;
}
}
void bitonic(int l, int r, bool inc){
if(l==r)return ;
assert(l<=r);
int md=(l+r)/2;
bitonic(l,md,inc);
bitonic(md+1,r,!inc);
for(int i = l;i<=md;i++){
assert(i+md+1-l<=xd);
compp(a[i],a[i+md+1-l]);
}
vector<int> vi = visit();
//if(vi.size()!=x)assert(0);
x = 0;
int ind = 0;
for(int i = l;i<=md;i++){
if(a[i+md+1-l]>n){
if(inc){
swap(a[i],a[i+(md+1-l)]);
}
}else if(a[i]>n){
if(!inc){
swap(a[i],a[i+(md+1-l)]);
}
}else{
if(ind>=vi.size())continue;
if((!inc)^(!vi[ind])){
swap(a[i],a[i+(md+1-l)]);
}
ind++;
}
}
bitonic(l,md,inc);
bitonic(md+1,r,inc);
}
void solve(int N,int V){
n = N;
xd = 1;
while(xd<N)xd*=2;
for(int i = 1;i<=xd;i++){
a[i] = i;
}
bitonic(1,xd,1);
vector<int> ans;
for(int i = xd-N+1;i<=xd;i++){
ans.push_back(a[i]);
}
answer(ans);
}
Compilation message
swaps.cpp: In function 'void bitonic(int, int, bool)':
swaps.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | if(ind>=vi.size())continue;
| ~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
33 ms |
436 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
27 ms |
416 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
20 ms |
436 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
20 ms |
436 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
27 ms |
340 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
27 ms |
340 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
18 ms |
428 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
18 ms |
428 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
19 ms |
428 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
19 ms |
428 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
27 ms |
420 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
27 ms |
420 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |