제출 #706838

#제출 시각아이디문제언어결과실행 시간메모리
706838grossly_overconfident순열 (APIO22_perm)C++17
10 / 100
2 ms340 KiB
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
set<long long> p;

vector<int> construct_permutation(long long k)
{
	int q = 1;
	if (p.empty()){
		while (pow(2, q) < LONG_LONG_MAX){
			p.insert(pow(2, q));
			q++;
			
		}
	}
	long long remaining = k - (k % 2);
	vector<int> out, found;
	int os = 0;
	if (k % 2 != 0){
		out.push_back(INT_MAX);
		os++;
	}
	int fs = 0;
	while (remaining > 0){
		
		long long t = *(--p.upper_bound(remaining));
		fs++;
		remaining -= t;
		found.push_back(t);
	}
	for (int i = 0; i < log2(found[0]); ++i){
		out.push_back(i * 2);
		os++;
	}
	for (int i = 1; i < fs; ++i){
		out.push_back((log2(found[i]) - 1) * 2 + 1);
		os++;
	}

	vector<int> outsorted = out;
	sort(outsorted.begin(), outsorted.end());

	for (int i = 0; i < os; ++i){
		for (int j = 0; j < os; ++j){
			if (outsorted[i] == out[j]){
				out[j] = i;
				break;
			}
		}
	}
	
	return out;
}

int no(){
	int n;
	cin >> n;
	auto g = construct_permutation(n);
	for (auto h : g){
		cout << h << endl;
	}
}

컴파일 시 표준 에러 (stderr) 메시지

perm.cpp: In function 'int no()':
perm.cpp:62:1: warning: no return statement in function returning non-void [-Wreturn-type]
   62 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...