This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<perm.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 22;
vector<int> solv(ll n, int mn){
vector<int> a;
if(n == 1) return a;
if(n % 15 == 0){
a = solv(n/15, mn);
int x, y, z, w, t;
if(a.empty()){
x = mn, y = mn + 1, z = mn + 2, w = mn + 3, t = mn + 4;
}else{
x = *max_element(all(a)) + 1;
y = x + 1;
z = y + 1;
w = z + 1;
t = w + 1;
}
a.pb(z);
a.pb(x);
a.pb(y);
a.pb(t);
a.pb(w);
return a;
}
if(n % 13 == 0){
a = solv(n/13, mn);
int x, y, z, w, t;
if(a.empty()){
x = mn, y = mn + 1, z = mn + 2, w = mn + 3, t = mn + 4;
}else{
x = *max_element(all(a)) + 1;
y = x + 1;
z = y + 1;
w = z + 1;
t = w + 1;
}
a.pb(y);
a.pb(z);
a.pb(t);
a.pb(w);
a.pb(x);
return a;
}
if(n % 11 == 0){
a = solv(n/11, mn);
int x, y, z, w, t;
if(a.empty()){
x = mn, y = mn + 1, z = mn + 2, w = mn + 3, t = mn + 4;
}else{
x = *max_element(all(a)) + 1;
y = x + 1;
z = y + 1;
w = z + 1;
t = w + 1;
}
a.pb(y);
a.pb(w);
a.pb(t);
a.pb(z);
a.pb(x);
return a;
}
if(n % 7 == 0){
a = solv(n/7, mn);
int x, y, z, w;
if(a.empty()){
x = mn, y = mn + 1, z = mn + 2, w = mn + 3;
}else{
x = *max_element(all(a)) + 1;
y = x + 1;
z = y + 1;
w = z + 1;
}
a.pb(y);
a.pb(w);
a.pb(z);
a.pb(x);
return a;
}
if(n % 5 == 0){
a = solv(n/5, mn);
int x, y, z;
if(a.empty()){
x = mn, y = mn + 1, z = mn + 2;
}else{
x = *max_element(all(a)) + 1;
y = x + 1;
z = y + 1;
}
a.pb(y);
a.pb(z);
a.pb(x);
return a;
}
if(n % 3 == 0){
a = solv(n/3, mn);
int x, y;
if(a.empty()){
x = mn, y = mn + 1;
}else{
x = *max_element(all(a)) + 1;
y = x + 1;
}
a.pb(y);
a.pb(x);
return a;
}
if(n % 2 == 0){
a = solv(n/2, mn);
int x;
if(a.empty())
x = mn;
else
x = *max_element(all(a)) + 1;
a.pb(x);
return a;
}
a = solv(n-1, mn+1);
a.pb(mn);
return a;
}
vector<int> construct_permutation(long long k){
return solv(k, 0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |