Submission #742503

# Submission time Handle Problem Language Result Execution time Memory
742503 2023-05-16T10:46:21 Z keisuke6 Permutation (APIO22_perm) C++17
91.3333 / 100
3 ms 340 KB
#include "perm.h"
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
 
vector<int> construct_permutation(long long k)
{
	vector<int> A = {};
	int now = 300;
	long long ans = 1;
	while(ans*2 <= k){
		A.push_back(now);
		ans *= 2;
		now++;
	}
	set<int> B;
	int n = A.size();
	for(int i=0;i<=n;i++){
		if((1ll<<(n-i))+ans <= k){
			B.insert(i);
			ans += (1ll<<(n-i));
		} 
	}
	vector<int> Ans = {};
	now = 100;
	for(int i=0;i<n;i++){
		if(B.count(i)) Ans.push_back(now);
		Ans.push_back(A[i]);
		now--;
	}
	if(B.count(n)) Ans.push_back(now);
	n = Ans.size();
	vector<int> Ansc = Ans;
	sort(Ans.begin(),Ans.end());
	map<int,int> m;
	for(int i=0;i<n;i++) m[Ans[i]] = i;
	vector<int> Ans_ = {};
	for(int i=0;i<n;i++) Ans_.push_back(m[Ansc[i]]);
	return Ans_;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Partially correct 2 ms 340 KB Partially correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 3 ms 296 KB Output is correct
8 Partially correct 3 ms 340 KB Partially correct
9 Correct 2 ms 340 KB Output is correct
10 Partially correct 3 ms 340 KB Partially correct
11 Partially correct 3 ms 340 KB Partially correct
12 Partially correct 3 ms 340 KB Partially correct
13 Partially correct 3 ms 312 KB Partially correct