Submission #735460

#TimeUsernameProblemLanguageResultExecution timeMemory
735460keisuke6Fun Tour (APIO20_fun)C++14
0 / 100
1 ms256 KiB
#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){ vector<int> B = {}; 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){ B.push_back(s-i); B.push_back(i); c+=2; } N -= c; c = 0; for(int i=(1<<d)-1;i<N;i++){ c += 2; A.push_back((1<<(d+1))-3-i); A.push_back(i); } N -= c; for(int x:B) A.push_back(x); continue; } int c = 0; for(int i=(1<<d)-1;i<N;i++){ c += 2; A.push_back((1<<(d+1))-3-i); A.push_back(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)

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:24:30: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   24 |     if(N+1-(1<<d) > (1<<(d-1)-1)/2+1){
      |                         ~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...