#include "fun.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
std::vector<int> createFunTour(int N, int Q) {
vector<int> per(N);
vector<int> bf1;
vector<int>bf2;
queue<int> q;
q.push(1);
while(!q.empty()){
int u=q.front();
cout << u << endl;
bf1.push_back(u);
q.pop();
if(u*2+1<N)q.push(u*2+1);
if(u*2+2<N)q.push(u*2+2);
}
q.push(2);
while(!q.empty()){
int u=q.front();
bf2.push_back(u);
q.pop();
if(u*2+1<N)q.push(u*2+1);
if(u*2+2<N)q.push(u*2+2);
}
reverse(bf1.begin(),bf1.end());
reverse(bf2.begin(),bf2.end());
bf1.push_back(0);
int i=0;
int j=0;
bool ch=false;
int cnt=0;
while(cnt<N){
per[cnt]=bf1[i];
i++;
cnt++;
if(cnt==N)break;
if(!ch){
per[cnt]=bf2[j];
j++;
cnt++;
if(j==bf2.size()){
ch=true;
j=bf1.size()-1;
}
}
else{
per[cnt]=bf1[j];
j--;
cnt++;
}
}
return per;
}
# | 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... |