제출 #928611

#제출 시각아이디문제언어결과실행 시간메모리
928611MilosMilutinovic순열 (APIO22_perm)C++17
91.33 / 100
1 ms756 KiB
#include "perm.h"
#include<bits/stdc++.h>
 
#define pb push_back
#define fi first
#define se second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
 
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
 
ll readint(){
	ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

vector<int> construct_permutation(ll k){
	vector<int> v(1,0);
	while((1ll<<((int)v.size()+1))<=k) v.pb(v.size());
	ll c=(1ll<<v.size());
	vector<int> new_v;
	int nxt=v.size();
	for(int i=(int)v.size()-1;i>=0;i--){
		new_v.pb(v[i]);
		if(c+(1ll<<i)<=k){
			new_v.pb(nxt);
			nxt++;
			c+=(1ll<<i);
		}
	}
	reverse(new_v.begin(),new_v.end());
	return new_v;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...