제출 #975520

#제출 시각아이디문제언어결과실행 시간메모리
975520KK_1729순열 (APIO22_perm)C++17
0 / 100
0 ms348 KiB
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;

int min(int x, int y){
	if (x < y) return x;
	return y;
}
std::vector<int> construct_permutation(long long k)
{	
	vector<int> a;
	while (k > 2){
		if (k%2 == 1){
			a.push_back(1);
			k--;
		}else{
			a.push_back(0);
			k/=2;
		}
	}
	reverse(a.begin(), a.end());


	int mini = -1; int maximum = 1;
	vector<int> ans;
	ans.push_back(0);
	for (auto x: a){
		if (x == 0){
			ans.push_back(maximum);
			maximum++;
		}else{
			ans.push_back(mini);
			mini--;

		}
	}
	int u = 1e9;
	for (auto x: ans){
		if (x < u) u = x;
	}
	for (int i = 0; i < ans.size(); ++i) ans[i] += u;
	return ans;
}

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for (int i = 0; i < ans.size(); ++i) ans[i] += u;
      |                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...