#include "swaps.h"
#include <bits/stdc++.h>
#define sz(a) (int)(a.size())
#define pb push_back
using namespace std;
int nn,pw = 1;
vector<int>v;
void bitonic(int n){
if(n==1)return;
int z = n/2;
for(int i=0;i<pw;i+=2*z){
for(int j=i;j<i+z;j++){
if(max(v[j],v[j+z]) <= nn)schedule(v[j],v[j+z]);
}
}
vector<int>res = visit();
int k = 0;
for(int i=0;i<pw;i+=2*z){
for(int j=i;j<i+z;j++){
if(max(v[j],v[j+z]) <= nn){
if(!res[k])swap(v[j],v[j+z]);
k++;
}else if(v[j] >nn)swap(v[j],v[j+z]);
}
}
bitonic(n/2);
}
void merge(int n){
if(n==1)return;
merge(n/2);
int z = n/2;
cout<<n<<'\n';
for(int i=0;i<pw;i+=2*z){
for(int j=i;j<i+z;j++){
if(max(v[j],v[j+z]) <= nn)schedule(v[j],v[j+z]);
}
}
vector<int>res = visit();
int k = 0;
for(int i=0;i<pw;i+=2*z){
for(int j=i;j<i+z;j++){
if(max(v[j],v[j+z]) <= nn){
if(!res[k])swap(v[j],v[j+z]);
k++;
}
}
for(int j=i+z;j<i+2*z;j++){
int inv = j-i-z;
inv = z-inv-1;
inv = i+z+inv;
if(inv > j)swap(v[j],v[inv]);
}
}
bitonic(n);
}
void solve(int n,int V){
nn = n;
while(pw<n)pw*=2;
for(int i=1;i<=pw;i++)v.push_back(i);
merge(pw);
vector<int>fin;
for(int x:v)if(x<=n)fin.pb(x);
answer(fin);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
304 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
304 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
300 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
300 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |