제출 #573159

#제출 시각아이디문제언어결과실행 시간메모리
573159Vanilla순열 (APIO22_perm)C++17
91.33 / 100
3 ms340 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; long long find (long long k) { for (long long i = 1; i < 63; i++){ if ((1ll << i) > k) return i-1; } } std::vector<int> construct_permutation(long long k) { vector <int> rs; long long pw [100] = {}; k-=2; int sp = 1000; pw[0] = sp - 1; rs.push_back(sp); int step = 1; while (k != 0) { int hg = min(int(find(k)), step); if (pw[hg] == 0) { pw[hg] = pw[hg - 1] + sp; } rs.push_back(pw[hg]--); k-=(1ll << hg); step++; } vector <int> v = rs; sort(v.begin(), v.end()); map <int, int> mp; for (int i = 0; i < v.size(); i++){ mp[v[i]] = i; } for (int &i: rs){ i = mp[i]; } return rs; } // int main (){ // construct_permutation(12); // }

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for (int i = 0; i < v.size(); i++){
      |                  ~~^~~~~~~~~~
perm.cpp: In function 'long long int find(long long int)':
perm.cpp:9:1: warning: control reaches end of non-void function [-Wreturn-type]
    9 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...