Submission #742495

#TimeUsernameProblemLanguageResultExecution timeMemory
742495keisuke6Permutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include "perm.h" #include <vector> #include <iostream> using namespace std; vector<int> construct_permutation(long long k) { vector<int> A = {}; int now = 300; int ans = 1; while(ans*2 <= k){ A.push_back(now); ans *= 2; now++; } set<int> B; int n = A.size(); for(int i=0;i<n;i++){ if((1ll<<(n-i-1))+ans <= k) B.insert(i); } vector<int> Ans = {}; now = 100; for(int i=0;i<n;i++){ Ans.push_back(A[i]); if(B.count(i)) Ans.push_back(now); now--; } return Ans; }

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:16:2: error: 'set' was not declared in this scope
   16 |  set<int> B;
      |  ^~~
perm.cpp:4:1: note: 'std::set' is defined in header '<set>'; did you forget to '#include <set>'?
    3 | #include <iostream>
  +++ |+#include <set>
    4 | using namespace std;
perm.cpp:16:6: error: expected primary-expression before 'int'
   16 |  set<int> B;
      |      ^~~
perm.cpp:19:31: error: 'B' was not declared in this scope
   19 |   if((1ll<<(n-i-1))+ans <= k) B.insert(i);
      |                               ^
perm.cpp:25:6: error: 'B' was not declared in this scope
   25 |   if(B.count(i)) Ans.push_back(now);
      |      ^