Submission #953651

# Submission time Handle Problem Language Result Execution time Memory
953651 2024-03-26T11:52:33 Z De3b0o Permutation (APIO22_perm) C++17
0 / 100
0 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;

std::vector<int> construct_permutation(long long k)
{
    vector<pll> v;
    ll p = 0;
    ll i = 0;
    k--;
    while(k>0)
    {
        if(k<i-p+1)
        {
            v.pb({p,i-1});
            p=i;
            continue;
        }
        if(k==i-p+1)
        {
            v.pb({p,i});
            p=i;
            k=0;
            continue;
        }
        k-=(i-p+1);
        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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -