Submission #896855

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

const int CT = 1000;

long long getdp(vector<int>& v) {
  vector<long long> dp(v.size() + 1, 0);
  dp[0] = 1;
  for (int x : v)
  {
  	for (int i = 0; i <= x; i++)
  	{
  		dp[x+1] += dp[i];
  		dp[x+1] = min(dp[x+1],MX+1);
  	}
  }
  long long result = 0;
  for (int i = 0; i <= (int)v.size(); i++){
  	result += dp[i];
  	result = min(result,MX+1);
  }
  return result;
}

vector<int> construct_permutation(long long k)
{
	const int CT = 1000;
	if(k <= 90){

		vector<int> v; 
		for(int i = 0; i<k; i++){
			v.push_back(k);
		}
		return v;
	}
	vector<int> v;
	for(int a = 1; i<=90; i++){
		v.push_back(a);
		if(a > 8){
			for(int _ = 0; _ < CT; _++){
				v = shuffle(v);
				if(getdp(v) == k){
					return v;
				}
			}
		}
		else{
			sort(v.begin(),v.end());
			do{
				if(getdp(v) == k) return v;
			}while(next_permutation(v.begin(),v.end()));
		}
		
	}
}

Compilation message (stderr)

perm.cpp: In function 'long long int getdp(std::vector<int>&)':
perm.cpp:15:27: error: 'MX' was not declared in this scope
   15 |     dp[x+1] = min(dp[x+1],MX+1);
      |                           ^~
perm.cpp:21:24: error: 'MX' was not declared in this scope
   21 |    result = min(result,MX+1);
      |                        ^~
perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:38:17: error: 'i' was not declared in this scope
   38 |  for(int a = 1; i<=90; i++){
      |                 ^
perm.cpp:42:18: error: no matching function for call to 'shuffle(std::vector<int>&)'
   42 |     v = shuffle(v);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from perm.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3748:5: note: candidate: 'template<class _RAIter, class _UGenerator> void std::shuffle(_RAIter, _RAIter, _UGenerator&&)'
 3748 |     shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3748:5: note:   template argument deduction/substitution failed:
perm.cpp:42:18: note:   candidate expects 3 arguments, 1 provided
   42 |     v = shuffle(v);
      |                  ^