Submission #704736

#TimeUsernameProblemLanguageResultExecution timeMemory
704736beaconmcPermutation (APIO22_perm)C++17
93.67 / 100
2 ms340 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include "perm.h"


typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)

using namespace std;


vector<int> construct_permutation(long long k)
{
	srand(time(0));
	ll imp = k;
	vector<ll> ops;
	deque<ll> sus;

	while (k>1){
		if (k%3==0 && rand()%3 == 0){

			ops.push_back(3);
			k/=3;
			continue;
		}
		if (k%2==0){
			ops.push_back(2);
			k /= 2;
		}else{
			ops.push_back(1);
			k -= 1;
		}
	}
	ll cur = 0;
	reverse(ops.begin(), ops.end());
	for (auto&i : ops){
		if (i==1) sus.push_front(cur);
		else if (i==2) sus.push_back(cur);
		else if (i==3) {
			sus.push_back(cur+1);
			sus.push_back(cur);
			cur++;
		}
		cur++;
	}
	vector<int> ans;
	for (auto&i : sus) ans.push_back(i);
	return ans;




}

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:16:5: warning: unused variable 'imp' [-Wunused-variable]
   16 |  ll imp = k;
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...