제출 #572595

#제출 시각아이디문제언어결과실행 시간메모리
572595arthur_nascimento순열 (APIO22_perm)C++17
컴파일 에러
0 ms0 KiB
std::vector<int> construct_permutation(long long k) { // k++; ll aux = k, sz = 0; while(aux) aux /= 2, sz++; vector<pii> ans; for(int i=0;i<sz-1;i++) ans.pb({2*i,i+1}); vector<int> dec; dec.pb(1); int x = 1, y = 0, skip = 0; for(int i=sz-2;i>=0;i--, x += 2, y--){ if((k & (1ll << i)) == 0) continue; if(skip){ skip = 0; ans.pb({x,dec[dec.size()-2]+1}); continue; } if(dec.size() == 1 || i == 0 || (k & (1ll << (i-1))) == 0){ ans.pb({x,y}); dec.pb(y); } else { skip = 1; } } sort(ans.begin(), ans.end()); int c = 0; for(auto &p : ans) p.first = c++; c = 0; sort(ans.begin(), ans.end(), [](pii i,pii j){ if(i.second == j.second) return i.first > j.first; return i.second < j.second; }); for(auto &p : ans) p.second = c++; sort(ans.begin(), ans.end()); vector<int> r; for(auto p : ans) r.pb(p.second); return r; }

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

perm.cpp:1:6: error: 'vector' in namespace 'std' does not name a template type
    1 | std::vector<int> construct_permutation(long long k)
      |      ^~~~~~
perm.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | std::vector<int> construct_permutation(long long k)