Submission #910994

#TimeUsernameProblemLanguageResultExecution timeMemory
910994efedmrlrPermutation (APIO22_perm)C++17
91.33 / 100
2 ms348 KiB
#include "perm.h" // #pragma GCC optimize("O3,Ofast,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define lli long long int #define MP make_pair #define pb push_back #define REP(i,n) for(int i = 0; (i) < (n); (i)++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const double EPS = 0.00001; const int INF = 1e9+500; const int N = 3e5+5; const int ALPH = 26; const int LGN = 60; constexpr int MOD = 1e9+7; int n,m,q; int big = 0; std::vector<int> construct_permutation(long long k) { vector<int> res; for(lli i = LGN - 1; i>=0; i--) { if(k & (1ll<<i)) { big = i; break; } } int nxt = 1; for(int i = 0; i<big; i++) { res.pb(nxt++); } for(lli i = big - 1; i>=0; i--) { if(k & (1ll<<i)) { auto itr = res.begin() + i; res.insert(itr, nxt++); } } vector<int> per(res.size()); for(int i = 0; i<res.size(); i++) { per[res[i] - 1] = i; } return per; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i = 0; i<res.size(); i++) {
      |                    ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...