답안 #574162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
574162 2022-06-08T05:15:50 Z Lawliet 순열 (APIO22_perm) C++17
91.3333 / 100
2 ms 340 KB
#include "perm.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> construct_permutation(long long k)
{
	int mn = 0;
	vector<int> ans;

	while( k > 1 )
	{
		if( k & 1 )
			ans.push_back( mn++ ), k ^= 1;
		else
			ans.push_back( -1 ), k >>= 1;
	}

	int mx = (int)ans.size() - 1;

	for(int i = 0 ; i < ans.size() ; i++)
		if( ans[i] == -1 ) ans[i] = mx--;

	reverse( ans.begin() , ans.end() );

	return ans;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i = 0 ; i < ans.size() ; i++)
      |                  ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 256 KB Output is correct
5 Partially correct 1 ms 340 KB Partially correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Partially correct 2 ms 340 KB Partially correct
9 Correct 1 ms 340 KB Output is correct
10 Partially correct 2 ms 340 KB Partially correct
11 Partially correct 2 ms 340 KB Partially correct
12 Partially correct 2 ms 340 KB Partially correct
13 Partially correct 2 ms 340 KB Partially correct