제출 #1363468

#제출 시각아이디문제언어결과실행 시간메모리
1363468Mamikonm1Permutation (APIO22_perm)C++20
91.33 / 100
1 ms356 KiB
//#include<game>
#include <iostream>
#include <vector>
#include <cmath>
#include<map>
#include <algorithm>
#include <iomanip>
#include <string>
#include<stack>
#include <set>
#include <queue>
#include <chrono>
#include<array>
#include<bitset>
#include<unordered_map>
#include<random>
#include<cassert>
#include<cstring>
using namespace std;
using ll = long long;
using db = double;
const float pi = 3.14159265359;
#define V vector
#define VI V<int>
#define P pair<int,int>
#define rep(i, a, b, step) for (int i = int(a); i <= int(b); i += step)
#define repl(i,a,b,step) for (int i = int(a); i >= int(b); i -= step)
#define sn << '\n'
#define ed << endl
#define sz size()
#define print cout <<
#define debug(x) cerr<< #x << " = " << x sn;
#define mpII map<int,int>   
#define mine min_element    
#define maxe max_element    
#define all(v) begin(v), end(v)
#define txt freopen("snakes.in", "r", stdin); freopen("snakes.out", "w", stdout)    
#define pb push_back    
#define pq priority_queue
#define rev reverse
#define nuyn(a) a.erase(unique(all(a)), end(a))
#define nx next_permutation         
#define pk pop_back()
#define START print "Start" sn
#define END print "End" sn
#define ff first
#define ss second       
#define ts to_string 
#define ub upper_bound       
#define mk make_pair 
#define lb lower_bound               
#define testcase int t;cin>>t;while(t--)solution();
void to_perm(VI& a) {
    VI b = a;
    sort(all(b));
    rep(i, 0, a.sz - 1, 1)a[i] = lb(all(b), a[i]) - begin(b);
}
std::vector<int> construct_permutation(long long k)
{
    VI ans, bt;
    rep(i, 0, 60, 1)if (k & (1ll << i))
        bt.pb(i);
    int mx = bt.back();
    rep(i, 0, mx - 2, 1)ans.pb(i * 2);
    repl(i, bt.sz - 1, 0, 1)ans.pb(bt[i] * 2 - 1);
 //   for (auto& i : bt)print i << ' ';
  //  print '\n';
    to_perm(ans);
    int n = ans.sz;
    V<ll>dp(n + 1);
    dp[0] = 1;
    ll sum = 1;
    rep(i, 1, n, 1) {
        dp[i] = 1;
        rep(j, 1, i - 1, 1)if (ans[j - 1] < ans[i - 1])
            dp[i] += dp[j];
        sum += dp[i];
    }
 //   debug(sum);
    return ans;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…