#include <bits/stdc++.h>
using namespace std;
#include "swaps.h"
int a[2001] = {0};
int n;
vector<int> nah;
/*void schedule(int a,int b){
if(rea[a]>rea[b]){
nah.push_back(1);
}else nah.push_back(0);
}*/
void comp(int a,int b){
if(b<=n&&a<=n){
schedule(a,b);
}
}/*
vector<int> visit(){
vector<int> xdd = nah;
nah.clear();
return xdd;
}*/
void bitonic(int l, int r, bool inc){
if(l==r)return ;
int md=(l+r)/2;
bitonic(l,md,inc);
bitonic(md+1,r,!inc);
vector<int> vi;
for(int i = l;i<=md;i++){
comp(a[i],a[i+md+1-l]);
}
vi = visit();
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((!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;
int 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);
}/*
int main(){
freopen("input.txt","r",stdin);
freopen("outout.txt","w",stdout);
/*rea[1] = 4, rea[2] = 1, rea[3] = 2 , rea[4] = 3 , rea[5] = 10;
a[1] =1 , a[2] = 2 , a[3] = 3 , a[4] = 4 , a[5] = 5 , a[6] = 6, a[7] = 7 , a[8] = 8;
n = 5;
bitonic(1,8,1);
for(int i = 1;i<=8;i++){
cout<<a[i]<<" ";
}
}*/
Compilation message
swaps.cpp:70:5: warning: "/*" within comment [-Wcomment]
70 | /*rea[1] = 4, rea[2] = 1, rea[3] = 2 , rea[4] = 3 , rea[5] = 10;
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
22 ms |
416 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
25 ms |
428 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
23 ms |
412 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
23 ms |
412 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
23 ms |
420 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
23 ms |
420 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
30 ms |
416 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
30 ms |
416 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Correct |
2 |
Runtime error |
21 ms |
412 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Correct |
2 |
Runtime error |
21 ms |
412 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
21 ms |
428 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Runtime error |
21 ms |
428 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |