#include <bits/stdc++.h>
#include "swaps.h"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
vector <int> r;
vector <pii> Q;
void Schedule(int i,int j){
schedule(r[i],r[j]);
Q.push_back({i,j});
}
void Visit(){//交换逆序元素,最多调用50次
if(!Q.size())return;
vector <int> res=visit();
rep(i,0,(int)res.size()-1)if(!res[i])swap(r[Q[i].fi],r[Q[i].se]);
Q.clear();
}
void solve(int n,int q){
rep(i,1,n)r.push_back(i);
for(int k=2;k<=2*n;k<<=1){
rep(i,0,n-1){
int x=i^(k-1);
if(i<x&&x<n)Schedule(i,x);
}
Visit();
for(int j=k>>2;j;j>>=1){
rep(i,0,n-1){
int x=i^j;
if(i<x&&x<n)Schedule(i,x);
}
Visit();
}
}
answer(r);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
1 ms |
292 KB |
Correct |
3 |
Correct |
2 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
300 KB |
Correct |
5 |
Correct |
4 ms |
304 KB |
Correct |
6 |
Correct |
4 ms |
300 KB |
Correct |
7 |
Correct |
6 ms |
300 KB |
Correct |
8 |
Correct |
6 ms |
296 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
3 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
7 ms |
296 KB |
Correct |
5 |
Correct |
5 ms |
304 KB |
Correct |
6 |
Correct |
5 ms |
296 KB |
Correct |
7 |
Correct |
5 ms |
308 KB |
Correct |
8 |
Correct |
5 ms |
296 KB |
Correct |
9 |
Correct |
4 ms |
296 KB |
Correct |
10 |
Correct |
4 ms |
300 KB |
Correct |
11 |
Correct |
7 ms |
296 KB |
Correct |
12 |
Correct |
5 ms |
304 KB |
Correct |
13 |
Correct |
4 ms |
296 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Correct |
2 |
Correct |
3 ms |
292 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Correct |
2 |
Correct |
3 ms |
292 KB |
Correct |
3 |
Correct |
1 ms |
200 KB |
Correct |
4 |
Correct |
1 ms |
200 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
3 ms |
200 KB |
Correct |
3 |
Correct |
2 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
300 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
3 ms |
200 KB |
Correct |
3 |
Correct |
2 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
300 KB |
Correct |
5 |
Correct |
1 ms |
200 KB |
Correct |
6 |
Correct |
2 ms |
292 KB |
Correct |
7 |
Correct |
2 ms |
200 KB |
Correct |
8 |
Correct |
6 ms |
296 KB |
Correct |
9 |
Correct |
6 ms |
300 KB |
Correct |
10 |
Correct |
4 ms |
296 KB |
Correct |
11 |
Correct |
5 ms |
300 KB |
Correct |
12 |
Correct |
6 ms |
296 KB |
Correct |
13 |
Correct |
1 ms |
200 KB |
Correct |
14 |
Correct |
1 ms |
284 KB |
Correct |
15 |
Correct |
2 ms |
200 KB |
Correct |
16 |
Correct |
6 ms |
328 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
2 ms |
200 KB |
Correct |
4 |
Correct |
5 ms |
300 KB |
Correct |
5 |
Correct |
5 ms |
284 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
2 ms |
200 KB |
Correct |
4 |
Correct |
5 ms |
300 KB |
Correct |
5 |
Correct |
5 ms |
284 KB |
Correct |
6 |
Correct |
1 ms |
200 KB |
Correct |
7 |
Correct |
1 ms |
200 KB |
Correct |
8 |
Correct |
3 ms |
200 KB |
Correct |
9 |
Correct |
4 ms |
300 KB |
Correct |
10 |
Correct |
5 ms |
300 KB |
Correct |
11 |
Correct |
5 ms |
300 KB |
Correct |
12 |
Correct |
4 ms |
296 KB |
Correct |
13 |
Correct |
6 ms |
408 KB |
Correct |
14 |
Correct |
6 ms |
300 KB |
Correct |
15 |
Correct |
8 ms |
296 KB |
Correct |
16 |
Correct |
5 ms |
436 KB |
Correct |
17 |
Correct |
6 ms |
296 KB |
Correct |
18 |
Correct |
4 ms |
300 KB |
Correct |
19 |
Correct |
1 ms |
200 KB |
Correct |
20 |
Correct |
2 ms |
284 KB |
Correct |
21 |
Correct |
2 ms |
200 KB |
Correct |
22 |
Correct |
4 ms |
300 KB |
Correct |
23 |
Correct |
4 ms |
276 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
1 ms |
328 KB |
Correct |
3 |
Correct |
2 ms |
200 KB |
Correct |
4 |
Correct |
5 ms |
296 KB |
Correct |
5 |
Correct |
5 ms |
284 KB |
Correct |
6 |
Correct |
4 ms |
280 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
1 ms |
328 KB |
Correct |
3 |
Correct |
2 ms |
200 KB |
Correct |
4 |
Correct |
5 ms |
296 KB |
Correct |
5 |
Correct |
5 ms |
284 KB |
Correct |
6 |
Correct |
4 ms |
280 KB |
Correct |
7 |
Correct |
1 ms |
200 KB |
Correct |
8 |
Correct |
1 ms |
288 KB |
Correct |
9 |
Correct |
2 ms |
200 KB |
Correct |
10 |
Correct |
5 ms |
300 KB |
Correct |
11 |
Correct |
5 ms |
300 KB |
Correct |
12 |
Correct |
4 ms |
296 KB |
Correct |
13 |
Correct |
4 ms |
300 KB |
Correct |
14 |
Correct |
4 ms |
304 KB |
Correct |
15 |
Correct |
4 ms |
296 KB |
Correct |
16 |
Correct |
4 ms |
296 KB |
Correct |
17 |
Correct |
5 ms |
300 KB |
Correct |
18 |
Correct |
6 ms |
292 KB |
Correct |
19 |
Correct |
4 ms |
296 KB |
Correct |
20 |
Correct |
1 ms |
200 KB |
Correct |
21 |
Correct |
1 ms |
200 KB |
Correct |
22 |
Correct |
3 ms |
200 KB |
Correct |
23 |
Correct |
4 ms |
304 KB |
Correct |
24 |
Correct |
4 ms |
288 KB |
Correct |
25 |
Correct |
6 ms |
288 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
2 ms |
280 KB |
Correct |
4 |
Correct |
5 ms |
416 KB |
Correct |
5 |
Correct |
5 ms |
320 KB |
Correct |
6 |
Correct |
5 ms |
284 KB |
Correct |
7 |
Correct |
6 ms |
264 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
2 ms |
280 KB |
Correct |
4 |
Correct |
5 ms |
416 KB |
Correct |
5 |
Correct |
5 ms |
320 KB |
Correct |
6 |
Correct |
5 ms |
284 KB |
Correct |
7 |
Correct |
6 ms |
264 KB |
Correct |
8 |
Correct |
1 ms |
200 KB |
Correct |
9 |
Correct |
1 ms |
200 KB |
Correct |
10 |
Correct |
3 ms |
284 KB |
Correct |
11 |
Correct |
3 ms |
200 KB |
Correct |
12 |
Correct |
6 ms |
296 KB |
Correct |
13 |
Correct |
4 ms |
300 KB |
Correct |
14 |
Correct |
6 ms |
304 KB |
Correct |
15 |
Correct |
5 ms |
300 KB |
Correct |
16 |
Correct |
5 ms |
336 KB |
Correct |
17 |
Correct |
5 ms |
300 KB |
Correct |
18 |
Correct |
5 ms |
372 KB |
Correct |
19 |
Correct |
4 ms |
300 KB |
Correct |
20 |
Correct |
5 ms |
300 KB |
Correct |
21 |
Correct |
5 ms |
296 KB |
Correct |
22 |
Correct |
1 ms |
200 KB |
Correct |
23 |
Correct |
1 ms |
292 KB |
Correct |
24 |
Correct |
3 ms |
200 KB |
Correct |
25 |
Correct |
7 ms |
300 KB |
Correct |
26 |
Correct |
6 ms |
280 KB |
Correct |
27 |
Correct |
7 ms |
280 KB |
Correct |
28 |
Correct |
6 ms |
280 KB |
Correct |