제출 #777308

#제출 시각아이디문제언어결과실행 시간메모리
777308yeyso순열 (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; vector<int> construct_permutation(long long k) { vector<long long> logs; int L = 0; for(long long i = 0; i <= log(k) * 2; i ++){ long long x = pow(2, i); if(x <= k) { logs.push_back(x); L = i; } else { break; } } //cout << logs[logs.size()-1]; vector<int> res(L, 0); k -= logs[logs.size()-1]; //int x = log(k+1) / log(2) + 1; iota(res.begin(), res.end(), 0); while(k > 0){ for(long long i = logs.size() - 1; i >= 0; i --){ if(logs[i] <= k){ res.insert(res.begin() + i, L); k -= logs[i]; break; } } L += 1; } /*for(int i = 0; i < res.size(); i ++){ cout << res[i] << " "; }*/ return res; } /* g++ -std=gnu++17 -Wall -O2 -static -o perm grader.cpp perm.cpp */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...