# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
735449 | keisuke6 | Fun Tour (APIO20_fun) | C++14 | 1 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "fun.h"
#include <iostream>
#include <queue>
#include <vector>
#include <set>
using namespace std;
std::vector<int> createFunTour(int N, int Q) {
vector<int> A = {};
while(N > 2){
int d = 0;
while((1<<(d+1)) <= N) d++;
if(N+1-(1<<d) > (1<<(d-1))){
int s = (1<<d)+(1<<(d+1))-3;
int c = 0;
for(int i=(1<<d)-1;i<(1<<d)-1+(1<<(d-1));i++)if(s-i < N && i < s-i){
A.push_back(i);
A.push_back(s-i);
c += 2;
}
N -= c;
continue;
}
if(N+1-(1<<d) > (1<<(d-1)-1)/2+1){
int s = (1<<d)+(1<<d)+(1<<(d-1))-3;
int c = 0;
for(int i=(1<<d)-1;i<=s-((1<<d)-1);i++)if(s-i < N && i < s-i){
A.push_back(i);
A.push_back(s-i);
c+=2;
}
N -= c;
continue;
}
int c = 0;
for(int i=(1<<d)-1;i<N;i++){
c += 2;
A.push_back(i);
A.push_back((1<<(d+1))-3-i);
}
N -= c;
if(clock()*1.0/CLOCKS_PER_SEC > 1.6) break;
}
if(N == 2){
A.push_back(0);
A.push_back(1);
}
if(N == 1) A.push_back(0);
return A;
}
Compilation message (stderr)
# | 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... |