#include "swaps.h"
#include<bits/stdc++.h>
using namespace std;
template<typename T>
using vec = vector<T>;
using ll = long long;
using vll = vec<ll>;
using pll = pair<ll,ll>;
#define pb push_back;
#define dbg(x) if(1) cerr << #x << ": " << x << endl;
int n;
void sched(int a, int b) {
if(a >= n or b >= n) return;
a++;b++;
schedule(a,b);
}
void solve(int N, int V) {
n = N;
int nPow = ceil(log2(N));
int nPad = 1<<nPow;
for(int i = 1; i <= nPow; i++) {
// dbg(i);
int blkSize = (1<<i);
// query(1, n-k+1) for all the blocks
for(int j = 0; j < N; j += blkSize) {
for(int k = 0; k < blkSize/2; k++) {
// dbg(j);
// dbg(k);
sched(j+k, j+blkSize-k-1);
}
}
visit();
if(i > 1) {
for(int k = blkSize/2; k > 1; k /= 2) {
for(int j = 0; j < N; j += 2*k) {
for(int l = 0; l < k; l++) {
// cerr << k << " " << j << " " << l << endl;
sched(j+l,j+k+l);
}
}
visit();
}
}
}
vec<int> ans(N);
iota(ans.begin(),ans.end(),1);
answer(ans);
}
/*
16 100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |