답안 #603054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
603054 2022-07-23T14:36:48 Z tutis 순열 (APIO22_perm) C++17
0 / 100
113 ms 262144 KB
#include "perm.h"
using namespace std;
#include <iostream>
#include <random>
#include <functional>
#include <cassert>
#include <map>
using ll = long long;
std::vector<int> construct_permutation(long long k, bool v)
{
	if (k == 1)
		return {};
	if (v)
	{
		if (k == 3)
			return {1, 0};
		if (k == 4)
			return {2, 1, 0};
	}
	if (k % 2 == 0)
	{
		vector<int>a = construct_permutation(k / 2, v);
		a.push_back((int)a.size());
		return a;
	}
	if (k % 4 == 3)
	{
		vector<int>a = construct_permutation(k - 3, true);
		for (int &i : a)
			if (i >= 2)
				i++;
		a.push_back(2);
		return a;
	}
	if (k % 2 == 1)
	{
		vector<int>a = construct_permutation(k - 1, v);
		a.insert(a.begin(), (int)a.size());
		return a;
	}
}

vector<int> construct_permutation(long long k)
{
	return construct_permutation(k, false);
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int, bool)':
perm.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
   41 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 113 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 113 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -