제출 #850015

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

vector<int> construct_permutation(long long k) {
    vector<int> ans(0);
    long long br = 2,y = 0;
    while(br <= k) {
        ans.push_back(y);
        y++;
        br*=2;
    }
    k-=br/2;
    for(long long i = y; i >= 0; i--) {
        if((1LL << i) <= k) {
            k-=(1LL << i);
            ans.push_back(i);
            for(int j = 0; j < ans.size()-1; j++) {
                if(ans[j] >= i) {
                    ans[j]++;
                }
            }
        }
    }
	return ans;
}

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

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