Submission #1312319

#TimeUsernameProblemLanguageResultExecution timeMemory
1312319lmaobruhPermutation (APIO22_perm)C++20
99.33 / 100
2 ms580 KiB
#include <bits/stdc++.h> #include "perm.h" using namespace std; #define ll long long #define eb emplace_back #define pb push_back #define fi first #define se second #define ii pair<int,int> #define ve vector #define all(x) x.begin(), x.end() #define fo(i,a,b) for (int i=(a); i<=(b); ++i) #define fd(i,a,b) for (int i=(a); i>=(b); --i) #define popcount(x) __builtin_popcountll(x) #define maxi(a, b) a = max(a, b) #define mini(a, b) a = min(a, b) #define siz(x) ((int)(x).size()) #define vi ve<int> #define _ << ' ' << const int N = 1e6+5, inf = 1e9+10, mod = 1e9+7; vi shift(vi v, int off) { for (int &x : v) x += off; return v; } vi construct_permutation(ll k) { assert(k > 0); if (k == 1) return {}; if (k == 2) return {0}; for (int x : {2, 3, 5}) { if (x == k) continue; if (k % x == 0) { vi tmp = construct_permutation(k / x); vi tmp1 = construct_permutation(x); tmp1 = shift(tmp1, siz(tmp)); for (int x : tmp1) tmp.pb(x); return tmp; } } vi res = construct_permutation(k / 2); res.pb(siz(res)); if (k % 2 == 0) { return res; } res.insert(res.begin(), siz(res)); return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...