Submission #796677

#TimeUsernameProblemLanguageResultExecution timeMemory
796677Trisanu_DasPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> construct_permutation(int k){
  vector<int> ans;
  long long pow_2 = 1, exp_2 = 0, flag = 0, curr = 0;
  while(pow_2 * 2 <= k) pow_2 *= 2, exp_2++;
  for(int i = exp_2 - 1; i > -1; i--){
    ans.push_back(l++);
	if((k >> i) & 1){
		if(i and (k >> (i-1) & 1) and flag > 1) ans.push_back(curr++), ans.insert(ans.begin() + 2, curr++), i--;
		else ans.insert(ans.begin(), curr++), flag++;
	}
  }
  return ans;
}

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(int)':
perm.cpp:9:19: error: 'l' was not declared in this scope
    9 |     ans.push_back(l++);
      |                   ^