제출 #643688

#제출 시각아이디문제언어결과실행 시간메모리
643688czhang2718순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #include "perm.h" std::vector<int> construct_permutation(long long k) { long long S=k; pair<int, vector<int>> mn={1e9, {}}; for(int k=(S%2)+1; k<=90; k+=2){ long long s=S-1+k; vector<int> v; assert(s%2==0); if(__builtin_popcountll(s)>k || s/2<k) continue; multiset<int> bi; for(int i=1; i<60; i++){ if(s&(1LL<<i)) bi.insert(i); } while(bi.size()<k){ auto it=bi.upper_bound(1); assert(it!=bi.end()); // cout << "split " << (*it) << "\n"; bi.insert((*it)-1); bi.insert((*it)-1); bi.erase(it); } int x=0; for(int i:bi){ // cout << "i " << i << "\n"; for(int j=x+i-1; j>=x; j--) v.push_back(j); x+=i; } reverse(v.begin(), v.end()); mn=min(mn, {v.size(), v}); } return mn.second; } int main(){ cin.tie(0)->sync_with_stdio(0); int k; cin >> k; for(int x:construct_permutation(k)) cout << x << " "; } // kindness is weakness

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:19:24: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |         while(bi.size()<k){
      |               ~~~~~~~~~^~
/usr/bin/ld: /tmp/ccgUtCJA.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccw9GFuC.o:perm.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status