Submission #983976

#TimeUsernameProblemLanguageResultExecution timeMemory
983976vjudge1Permutation (APIO22_perm)C++17
0 / 100
0 ms348 KiB
#include <time.h> #include <cstdlib> #include <stack> #include <numeric> #include <unordered_map> #include <unordered_set> #include <iomanip> #include <map> #include <set> #include <iterator> #include <deque> #include <queue> #include <sstream> #include <array> #include <string> #include <tuple> #include <chrono> #include <cassert> #include <cstdio> #include <cstring> #include <list> #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <bitset> #include "perm.h" #define ll long long using namespace std; std::vector<int> construct_permutation(long long k){ vector<int> ans, v; deque<vector<int>> d; for(ll i = 62; i >= 0; i--){ if(k >= (1ll << i)){ k -= (1ll << i); v.push_back(i); } } for(int i = 0; i < v[0]; i++) ans.push_back(i); v.erase(v.begin()); while(!v.empty()){ int num = v.back(); vector<int> dop = ans, neww; while(num > 0){ num--; neww.push_back(dop.back() + 1); dop.pop_back(); } reverse(neww.begin(), neww.end()); for(int i = 0; i < dop.size(); i++) dop[i]++; ans = dop; ans.push_back(0); for(int to : neww) ans.push_back(to); v.pop_back(); } return ans; } // int main(){ // ll n; // cin >> n; // vector<int> res = construct_permutation(n); // for(int to : res) // cout << to << " "; // }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:51:20: 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 < dop.size(); i++)
      |                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...