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 <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
const int MOD=1e9+7;
int n;
long long num[63];
long long ft[201];
void upd(int x,long long v){
while (x<=n){
ft[x]+=v;
if (ft[x]>1e18) ft[x]=1e18+1;
x+=x&-x;
}
}
long long qry(int x){
long long res=0;
while (x>0){
res+=ft[x];
if (res>1e18) res=1e18+1;
x-=x&-x;
}
return res;
}
int lol(vector<int> arr){
n=arr.size();
long long res=1;
for (int i=1;i<=n;i++) ft[i]=0;
for (auto i:arr){
long long cur=qry(i+1)+1;
upd(i+1,cur);
res+=cur;
}
//cout<<"try ";
//for (auto i:arr) cout<<i<<' ';
//cout<<res<<'\n';
return res;
}
vector<int> construct_permutation(long long k){
vector<int> temp;
if (k==1) return temp;
temp.pb(0);
if (k==2) return temp;
vector<int> lol=construct_permutation(k/2);
lol.pb(lol.size());
if (k%2==1){
temp.clear();
temp.pb(lol.size());
for (auto i:lol) temp.pb(i);
return temp;
}
return lol;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |