Submission #739166

#TimeUsernameProblemLanguageResultExecution timeMemory
739166PixelCatPermutation (APIO22_perm)C++17
100 / 100
23 ms368 KiB
#include "perm.h" #ifdef NYAOWO #include "grader.cpp" #endif #include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define sz(x) ((int32_t)x.size()) #define all(x) x.begin(), x.end() #define eb emplace_back #define int LL using namespace std; using LL = long long; using pii = pair<int, int>; deque<int32_t> solve(int k, int32_t add) { if(k == 1) return deque<int32_t>(0); vector<int32_t> oao[] = { {2, 0}, {3, 1, 0}, {5, 1, 2, 0}, {7, 1, 3, 2, 0}, }; for(auto &v:oao) if(k % v[0] == 0) { auto a = solve(k / v[0], add + sz(v) - 1); Forr(i, sz(v) - 1, 1) a.push_front(add + v[i]); return a; } auto a = solve(k - 1, add + 1); a.push_back(add); return a; } std::vector<int32_t> construct_permutation(long long k) { auto res = solve(k, 0); vector<int32_t> a(all(res)); for(auto &i:a) cerr << i << " "; cerr << "\n"; return a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...