Submission #1168676

#TimeUsernameProblemLanguageResultExecution timeMemory
1168676mnbvcxz123Permutation (APIO22_perm)C++20
Compilation error
0 ms0 KiB
#include "perm.h"
#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

vector<signed> construct_permutation(long long k){
	k-=2;
	vector<int> sm(1000,0);
	vector<signed> v;
	sm[0]=1;
	v.push_back(0);
	int x=1;
	while(k>0){
		for (int i =  sz(v); i>=0; i--)
		{
			int s=1;
			for (int j = 0; j < i; j++)
			{
				if(v[j]<x) s+=sm[j];
			}
			if(s<=k){
				sm[x]+=s;
				v.insert(v.begin() + i, x);
				k-=s;
				ok=0;
				break;
			}
		}
		x++;
	}
	return v;
}

Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:28:33: error: 'ok' was not declared in this scope; did you mean 'k'?
   28 |                                 ok=0;
      |                                 ^~
      |                                 k