#include "swaps.h"
#include<bits/stdc++.h>
using namespace std;
int N;
vector<int> q;
//N 以上は小さい方が高い
void sch(int i,int j){
if(i<N&&j<N){
q.push_back(-1);
schedule(i+1,j+1);
}
else if(i<N){
q.push_back(1);
}
else if(j<N){
q.push_back(0);
}
else if(i<j){
q.push_back(1);
}
else{
q.push_back(0);
}
}
vector<int> my_visit(){
vector<int> r=visit();
vector<int> ret;
int i=0;
for(auto e:q){
if(e==-1){
ret.push_back(r[i]);
i++;
}
else{
ret.push_back(e);
}
}
q.clear();
return ret;
}
void solve(int n, int v) {
N=n;
//bitonic sort ですか?
int m=1;
int k=0;
while(m<n){
m*=2;
k++;
}
vector<int> a(m);
iota(a.begin(),a.end(),0);
for(int i=0;i<k;i++){
//前提条件:長さ 2^i のブロックは全てソート済み(奇数ブロック目は逆順ソート)
for(int j=i;j>=0;j--){
vector<pair<int,int>> s;
for(int k=0;k<m;k+=(1<<(j+1))){
for(int l=0;l<(1<<j);l++){
sch(a[k+l],a[k+l+(1<<j)]);
}
}
vector<int> r=my_visit();
int idx=0;
int rev=1;
for(int k=0;k<m;k+=(1<<(j+1))){
if(k%(1<<(i+1))==0) rev^=1;
for(int l=0;l<(1<<j);l++){
if((r[idx]^rev^1)){
swap(a[k+l],a[k+l+(1<<j)]);
}
idx++;
}
}
}
}
vector<int> ans;
for(int i=0;i<n;i++) ans.push_back(a[i]+1);
answer(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
1 ms |
344 KB |
Correct |
4 |
Correct |
3 ms |
440 KB |
Correct |
5 |
Correct |
3 ms |
444 KB |
Correct |
6 |
Correct |
3 ms |
344 KB |
Correct |
7 |
Correct |
4 ms |
440 KB |
Correct |
8 |
Correct |
5 ms |
592 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
1 ms |
344 KB |
Correct |
4 |
Correct |
3 ms |
444 KB |
Correct |
5 |
Correct |
2 ms |
344 KB |
Correct |
6 |
Correct |
4 ms |
448 KB |
Correct |
7 |
Correct |
5 ms |
344 KB |
Correct |
8 |
Correct |
3 ms |
388 KB |
Correct |
9 |
Correct |
2 ms |
344 KB |
Correct |
10 |
Correct |
3 ms |
344 KB |
Correct |
11 |
Correct |
3 ms |
580 KB |
Correct |
12 |
Correct |
3 ms |
344 KB |
Correct |
13 |
Correct |
3 ms |
444 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
1 ms |
344 KB |
Correct |
4 |
Correct |
1 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
2 ms |
344 KB |
Correct |
4 |
Correct |
3 ms |
440 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
2 ms |
344 KB |
Correct |
4 |
Correct |
3 ms |
440 KB |
Correct |
5 |
Correct |
1 ms |
344 KB |
Correct |
6 |
Correct |
1 ms |
436 KB |
Correct |
7 |
Correct |
2 ms |
344 KB |
Correct |
8 |
Correct |
3 ms |
344 KB |
Correct |
9 |
Correct |
3 ms |
440 KB |
Correct |
10 |
Correct |
3 ms |
344 KB |
Correct |
11 |
Correct |
3 ms |
344 KB |
Correct |
12 |
Correct |
3 ms |
448 KB |
Correct |
13 |
Correct |
1 ms |
344 KB |
Correct |
14 |
Correct |
1 ms |
344 KB |
Correct |
15 |
Correct |
2 ms |
344 KB |
Correct |
16 |
Correct |
3 ms |
440 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
3 ms |
344 KB |
Correct |
4 |
Correct |
4 ms |
448 KB |
Correct |
5 |
Correct |
3 ms |
444 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
3 ms |
344 KB |
Correct |
4 |
Correct |
4 ms |
448 KB |
Correct |
5 |
Correct |
3 ms |
444 KB |
Correct |
6 |
Correct |
0 ms |
344 KB |
Correct |
7 |
Correct |
1 ms |
344 KB |
Correct |
8 |
Correct |
1 ms |
344 KB |
Correct |
9 |
Correct |
5 ms |
344 KB |
Correct |
10 |
Correct |
4 ms |
444 KB |
Correct |
11 |
Correct |
4 ms |
444 KB |
Correct |
12 |
Correct |
3 ms |
444 KB |
Correct |
13 |
Correct |
3 ms |
444 KB |
Correct |
14 |
Correct |
3 ms |
444 KB |
Correct |
15 |
Correct |
3 ms |
344 KB |
Correct |
16 |
Correct |
2 ms |
440 KB |
Correct |
17 |
Correct |
3 ms |
568 KB |
Correct |
18 |
Correct |
3 ms |
596 KB |
Correct |
19 |
Correct |
0 ms |
344 KB |
Correct |
20 |
Correct |
1 ms |
344 KB |
Correct |
21 |
Correct |
2 ms |
344 KB |
Correct |
22 |
Correct |
4 ms |
444 KB |
Correct |
23 |
Correct |
3 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
2 ms |
440 KB |
Correct |
3 |
Correct |
1 ms |
344 KB |
Correct |
4 |
Correct |
5 ms |
344 KB |
Correct |
5 |
Correct |
4 ms |
440 KB |
Correct |
6 |
Correct |
4 ms |
400 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
2 ms |
440 KB |
Correct |
3 |
Correct |
1 ms |
344 KB |
Correct |
4 |
Correct |
5 ms |
344 KB |
Correct |
5 |
Correct |
4 ms |
440 KB |
Correct |
6 |
Correct |
4 ms |
400 KB |
Correct |
7 |
Correct |
0 ms |
344 KB |
Correct |
8 |
Correct |
1 ms |
344 KB |
Correct |
9 |
Correct |
1 ms |
344 KB |
Correct |
10 |
Correct |
4 ms |
824 KB |
Correct |
11 |
Correct |
4 ms |
692 KB |
Correct |
12 |
Correct |
3 ms |
344 KB |
Correct |
13 |
Correct |
4 ms |
344 KB |
Correct |
14 |
Correct |
3 ms |
344 KB |
Correct |
15 |
Correct |
2 ms |
440 KB |
Correct |
16 |
Correct |
3 ms |
444 KB |
Correct |
17 |
Correct |
3 ms |
344 KB |
Correct |
18 |
Correct |
2 ms |
344 KB |
Correct |
19 |
Correct |
4 ms |
344 KB |
Correct |
20 |
Correct |
1 ms |
344 KB |
Correct |
21 |
Correct |
1 ms |
440 KB |
Correct |
22 |
Correct |
2 ms |
344 KB |
Correct |
23 |
Correct |
5 ms |
344 KB |
Correct |
24 |
Correct |
3 ms |
344 KB |
Correct |
25 |
Correct |
4 ms |
424 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
1 ms |
344 KB |
Correct |
4 |
Correct |
2 ms |
440 KB |
Correct |
5 |
Correct |
3 ms |
344 KB |
Correct |
6 |
Correct |
3 ms |
596 KB |
Correct |
7 |
Correct |
5 ms |
416 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
344 KB |
Correct |
3 |
Correct |
1 ms |
344 KB |
Correct |
4 |
Correct |
2 ms |
440 KB |
Correct |
5 |
Correct |
3 ms |
344 KB |
Correct |
6 |
Correct |
3 ms |
596 KB |
Correct |
7 |
Correct |
5 ms |
416 KB |
Correct |
8 |
Correct |
1 ms |
344 KB |
Correct |
9 |
Correct |
0 ms |
344 KB |
Correct |
10 |
Correct |
1 ms |
344 KB |
Correct |
11 |
Correct |
2 ms |
344 KB |
Correct |
12 |
Correct |
3 ms |
448 KB |
Correct |
13 |
Correct |
5 ms |
344 KB |
Correct |
14 |
Correct |
2 ms |
344 KB |
Correct |
15 |
Correct |
3 ms |
448 KB |
Correct |
16 |
Correct |
3 ms |
452 KB |
Correct |
17 |
Correct |
3 ms |
440 KB |
Correct |
18 |
Correct |
2 ms |
344 KB |
Correct |
19 |
Correct |
3 ms |
444 KB |
Correct |
20 |
Correct |
4 ms |
344 KB |
Correct |
21 |
Correct |
3 ms |
344 KB |
Correct |
22 |
Correct |
0 ms |
344 KB |
Correct |
23 |
Correct |
1 ms |
436 KB |
Correct |
24 |
Correct |
1 ms |
424 KB |
Correct |
25 |
Correct |
4 ms |
840 KB |
Correct |
26 |
Correct |
3 ms |
444 KB |
Correct |
27 |
Correct |
3 ms |
444 KB |
Correct |
28 |
Correct |
4 ms |
420 KB |
Correct |