제출 #968412

#제출 시각아이디문제언어결과실행 시간메모리
96841212345678순열 (APIO22_perm)C++17
91.33 / 100
2 ms348 KiB
#include "perm.h" #include <bits/stdc++.h> using namespace std; #define ll long long int mx, cnt; ll p[62]; vector<int> res, l; std::vector<int> construct_permutation(long long k) { p[0]=1; for (int i=1; i<62; i++) p[i]=p[i-1]*2; mx=cnt=0; res.clear(); l.clear(); ll tmp=k; while (tmp>0) { if (tmp%2==1) mx=max(mx, cnt), l.push_back(cnt); tmp/=2; cnt++; } for (int i=0; i<mx; i++) res.push_back(i); l.pop_back(); reverse(l.begin(), l.end()); for (auto x:l) { for (int i=x; i<res.size(); i++) res[i]++; res.push_back(x); } //for (auto x:res) cout<<x<<' '; //cout<<'\n'; return res; } //0 1 2 3 4 5 //1 2 4 8 16 32

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

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