제출 #852794

#제출 시각아이디문제언어결과실행 시간메모리
852794adhityamv순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long vector<int> construct_permutation(ll k){ ll pow2[60]; pow2[0]=1LL; for(int i=1;i<60;i++) pow2[i]=2LL*pow2[i-1]; vector<int> bnry; int e=59; while(pow2[e]>k) e--; while(e>=0){ if(k>pow2[e]){ k-=pow2[e]; bnry.push_back(1); } else bnry.push_back(0); e--; } int mn=0; int mx=0; vector<int> ans; as.push_back(0); int m=(int) bnry.size(); for(int i=1;i<m;i++){ if(bnry[i]==0){ ans.push_back(mx+1); mx++; } else{ ans.push_back(mn-1); mn--; ans.push_back(mx); mx++; } } int l=ans.size(); for(int i=0;i<l;i++){ ans[i]-=(mn); } return ans; }

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

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:21:5: error: 'as' was not declared in this scope; did you mean 'ans'?
   21 |     as.push_back(0);
      |     ^~
      |     ans