#include <bits/stdc++.h>
using namespace std;
#include "swaps.h"
int a[2001] = {0};
vector<array<int,3>> v[100001];
int n;int lel =0;
vector<int> nah;
void comp(int a,int b){
if(b<=n&&a<=n){
schedule(a,b);
}
}
int bitonic(int l, int r, bool inc , bool all ,int lvl){
if(l==r)return lvl-1;
int md=(l+r)/2;
int ma = lvl-1;
if(all){
ma = bitonic(l,md,inc,1,lvl);
bitonic(md+1,r,!inc,1,lvl);
}
lel++;
vector<int> vi;
for(int i = l;i<=md;i++){
v[ma+1].push_back({i,i+md+1-l,inc});
//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(ind>=vi.size()){
assert(0);
}
if((!inc)^(!vi[ind])){
swap(a[i],a[i+(md+1-l)]);
}
ind++;
}
}*/
bitonic(l,md,inc,0,ma+2);
return bitonic(md+1,r,inc,0,ma+2);
}
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;
}
int ma = bitonic(1,xd,1,1,0);
for(int i = 0;i<=ma;i++){
for(auto j:v[i]){
comp(a[j[0]],a[j[1]]);
}
vector<int> vi = visit();
int ind = 0;
for(auto j:v[i]){
if(a[j[1]]>n){
if(j[2]){
swap(a[j[0]],a[j[1]]);
}
}else if(a[j[0]]>n){
if(!j[2]){
swap(a[j[0]],a[j[1]]);
}
}else{
if(ind>=vi.size()){
assert(0);
}
if((!j[2])^(!vi[ind])){
swap(a[j[0]],a[j[1]]);
}
ind++;
}
}
}
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 solve(int, int)':
swaps.cpp:77:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
77 | if(ind>=vi.size()){
| ~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Correct |
2 |
Correct |
1 ms |
2648 KB |
Correct |
3 |
Correct |
3 ms |
2868 KB |
Correct |
4 |
Correct |
5 ms |
3200 KB |
Correct |
5 |
Correct |
4 ms |
3200 KB |
Correct |
6 |
Correct |
4 ms |
2944 KB |
Correct |
7 |
Correct |
4 ms |
2948 KB |
Correct |
8 |
Correct |
5 ms |
2948 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Correct |
2 |
Correct |
2 ms |
2648 KB |
Correct |
3 |
Correct |
3 ms |
2864 KB |
Correct |
4 |
Correct |
6 ms |
3700 KB |
Correct |
5 |
Correct |
5 ms |
2948 KB |
Correct |
6 |
Correct |
5 ms |
2948 KB |
Correct |
7 |
Correct |
4 ms |
2944 KB |
Correct |
8 |
Correct |
5 ms |
2944 KB |
Correct |
9 |
Correct |
5 ms |
2944 KB |
Correct |
10 |
Correct |
5 ms |
3156 KB |
Correct |
11 |
Correct |
5 ms |
2948 KB |
Correct |
12 |
Correct |
5 ms |
2944 KB |
Correct |
13 |
Correct |
5 ms |
2952 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Correct |
2 |
Correct |
1 ms |
2648 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Correct |
2 |
Correct |
1 ms |
2648 KB |
Correct |
3 |
Correct |
1 ms |
2648 KB |
Correct |
4 |
Correct |
2 ms |
2648 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Correct |
2 |
Correct |
2 ms |
2648 KB |
Correct |
3 |
Correct |
2 ms |
2864 KB |
Correct |
4 |
Correct |
4 ms |
3156 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Correct |
2 |
Correct |
2 ms |
2648 KB |
Correct |
3 |
Correct |
2 ms |
2864 KB |
Correct |
4 |
Correct |
4 ms |
3156 KB |
Correct |
5 |
Correct |
2 ms |
2648 KB |
Correct |
6 |
Correct |
2 ms |
2648 KB |
Correct |
7 |
Correct |
2 ms |
2856 KB |
Correct |
8 |
Correct |
4 ms |
3196 KB |
Correct |
9 |
Correct |
5 ms |
2948 KB |
Correct |
10 |
Correct |
5 ms |
3200 KB |
Correct |
11 |
Correct |
4 ms |
3452 KB |
Correct |
12 |
Correct |
6 ms |
3196 KB |
Correct |
13 |
Correct |
1 ms |
2648 KB |
Correct |
14 |
Correct |
2 ms |
2648 KB |
Correct |
15 |
Correct |
3 ms |
2860 KB |
Correct |
16 |
Correct |
5 ms |
3444 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Correct |
2 |
Correct |
2 ms |
2648 KB |
Correct |
3 |
Correct |
3 ms |
2864 KB |
Correct |
4 |
Correct |
4 ms |
3196 KB |
Correct |
5 |
Correct |
4 ms |
3452 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Correct |
2 |
Correct |
2 ms |
2648 KB |
Correct |
3 |
Correct |
3 ms |
2864 KB |
Correct |
4 |
Correct |
4 ms |
3196 KB |
Correct |
5 |
Correct |
4 ms |
3452 KB |
Correct |
6 |
Correct |
1 ms |
2648 KB |
Correct |
7 |
Correct |
2 ms |
2648 KB |
Correct |
8 |
Correct |
3 ms |
2864 KB |
Correct |
9 |
Correct |
5 ms |
3444 KB |
Correct |
10 |
Correct |
5 ms |
3196 KB |
Correct |
11 |
Correct |
5 ms |
3200 KB |
Correct |
12 |
Correct |
5 ms |
2948 KB |
Correct |
13 |
Correct |
4 ms |
2948 KB |
Correct |
14 |
Correct |
5 ms |
2944 KB |
Correct |
15 |
Correct |
4 ms |
2948 KB |
Correct |
16 |
Correct |
5 ms |
2948 KB |
Correct |
17 |
Correct |
4 ms |
3452 KB |
Correct |
18 |
Correct |
5 ms |
2948 KB |
Correct |
19 |
Correct |
1 ms |
2648 KB |
Correct |
20 |
Correct |
1 ms |
2648 KB |
Correct |
21 |
Correct |
4 ms |
2864 KB |
Correct |
22 |
Correct |
5 ms |
3196 KB |
Correct |
23 |
Correct |
4 ms |
2948 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Correct |
2 |
Correct |
2 ms |
2648 KB |
Correct |
3 |
Correct |
3 ms |
2864 KB |
Correct |
4 |
Correct |
5 ms |
2944 KB |
Correct |
5 |
Correct |
4 ms |
3196 KB |
Correct |
6 |
Correct |
5 ms |
3176 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Correct |
2 |
Correct |
2 ms |
2648 KB |
Correct |
3 |
Correct |
3 ms |
2864 KB |
Correct |
4 |
Correct |
5 ms |
2944 KB |
Correct |
5 |
Correct |
4 ms |
3196 KB |
Correct |
6 |
Correct |
5 ms |
3176 KB |
Correct |
7 |
Correct |
1 ms |
2648 KB |
Correct |
8 |
Correct |
2 ms |
2648 KB |
Correct |
9 |
Correct |
3 ms |
2860 KB |
Correct |
10 |
Correct |
5 ms |
2944 KB |
Correct |
11 |
Correct |
5 ms |
3204 KB |
Correct |
12 |
Correct |
5 ms |
3196 KB |
Correct |
13 |
Correct |
5 ms |
3196 KB |
Correct |
14 |
Correct |
5 ms |
2944 KB |
Correct |
15 |
Correct |
5 ms |
3200 KB |
Correct |
16 |
Correct |
5 ms |
3200 KB |
Correct |
17 |
Correct |
4 ms |
2948 KB |
Correct |
18 |
Correct |
5 ms |
3200 KB |
Correct |
19 |
Correct |
4 ms |
2944 KB |
Correct |
20 |
Correct |
1 ms |
2648 KB |
Correct |
21 |
Correct |
2 ms |
2648 KB |
Correct |
22 |
Correct |
3 ms |
2860 KB |
Correct |
23 |
Correct |
5 ms |
3196 KB |
Correct |
24 |
Correct |
5 ms |
2944 KB |
Correct |
25 |
Correct |
5 ms |
3068 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Correct |
2 |
Correct |
2 ms |
2648 KB |
Correct |
3 |
Correct |
3 ms |
2864 KB |
Correct |
4 |
Correct |
6 ms |
3196 KB |
Correct |
5 |
Correct |
5 ms |
2948 KB |
Correct |
6 |
Correct |
5 ms |
3060 KB |
Correct |
7 |
Correct |
5 ms |
3072 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Correct |
2 |
Correct |
2 ms |
2648 KB |
Correct |
3 |
Correct |
3 ms |
2864 KB |
Correct |
4 |
Correct |
6 ms |
3196 KB |
Correct |
5 |
Correct |
5 ms |
2948 KB |
Correct |
6 |
Correct |
5 ms |
3060 KB |
Correct |
7 |
Correct |
5 ms |
3072 KB |
Correct |
8 |
Correct |
2 ms |
2648 KB |
Correct |
9 |
Correct |
1 ms |
2648 KB |
Correct |
10 |
Correct |
2 ms |
2648 KB |
Correct |
11 |
Correct |
2 ms |
2860 KB |
Correct |
12 |
Correct |
5 ms |
3200 KB |
Correct |
13 |
Correct |
4 ms |
2944 KB |
Correct |
14 |
Correct |
5 ms |
2944 KB |
Correct |
15 |
Correct |
5 ms |
3108 KB |
Correct |
16 |
Correct |
4 ms |
2956 KB |
Correct |
17 |
Correct |
5 ms |
2948 KB |
Correct |
18 |
Correct |
5 ms |
2948 KB |
Correct |
19 |
Correct |
4 ms |
2948 KB |
Correct |
20 |
Correct |
5 ms |
3448 KB |
Correct |
21 |
Correct |
5 ms |
3448 KB |
Correct |
22 |
Correct |
1 ms |
2896 KB |
Correct |
23 |
Correct |
2 ms |
2648 KB |
Correct |
24 |
Correct |
3 ms |
2864 KB |
Correct |
25 |
Correct |
5 ms |
3200 KB |
Correct |
26 |
Correct |
4 ms |
3204 KB |
Correct |
27 |
Correct |
5 ms |
2940 KB |
Correct |
28 |
Correct |
4 ms |
3364 KB |
Correct |