Submission #980740

#TimeUsernameProblemLanguageResultExecution timeMemory
980740MalixPermutation (APIO22_perm)C++17
71.22 / 100
11 ms1456 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int,int> pi; typedef vector<pi> pii; #define REP(i,a,b) for(int i=a;i<b;i++) #define F first #define S second #define PB push_back #define MP make_pair ll INF=1e18+10; std::vector<int> construct_permutation(long long k) { if(k==1)return {}; //k--; vi ans; int pos=-1; vector<ll> a(70,INF); REP(i,0,64)a[i]=pow(2,i); bool flag=1; while(k){ int it=lower_bound(a.begin(),a.end(),k)-a.begin(); if(a[it]!=k)it--; k-=a[it]; pos+=it; int pos2=pos; while(it){ ans.PB(pos); pos--; it--; } pos=pos2; if(flag){ REP(i,0,64)a[i]--; flag=0; } } reverse(ans.begin(),ans.end()); //REP(i,0,ans.size())cout<<ans[i]<<" "; return ans; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:30:11: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<long long unsigned int>, long long unsigned int>::value_type' {aka 'long long unsigned int'} and 'long long int' [-Wsign-compare]
   30 |   if(a[it]!=k)it--;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...