답안 #953653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
953653 2024-03-26T11:56:13 Z De3b0o 순열 (APIO22_perm) C++17
10 / 100
2 ms 348 KB
#include "perm.h"
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
//#define lc (2*n)
//#define rc (2*n+1)

using namespace std;

ll mo = 1e9+7;

ll fp(ll x , ll y)
{
    if(y==0)
        return 1;
    ll z = fp(x,y/2);
    if(y&1)
        return z*z%mo*x%mo;
    else
        return z*z%mo;
}

std::vector<int> construct_permutation(long long k)
{
    vector<pll> v;
    ll p = 0;
    ll i = 0;
    k--;
    while(k>0)
    {
        ll x = fp(2,i-p);
        if(k<x)
        {
            v.pb({p,i-1});
            p=i;
            continue;
        }
        if(k==x)
        {
            v.pb({p,i});
            p=i;
            k=0;
            continue;
        }
        k-=x;
        i++;
    }
    vector<int> ans(p+1,0);
    ll x = 0;
    for(int i = v.size()-1 ; i>=0 ; i--)
    {
        for(int j = v[i].F ; v[i].S >=j ; j++)
        {
            ans[j]=x;
            x++;
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Partially correct 2 ms 348 KB Partially correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -