Submission #718417

#TimeUsernameProblemLanguageResultExecution timeMemory
718417vjudge1Permutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
#include "perm.h"
#include <bits/stdc++.h>

long long count_increasing(const 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;
}
std::vector<int> construct_permutation(long long k)
{
	vector <int> ans;
	//return ans;
	for(int i = 0;; ++i){
		vector <int> tmp;
		int sz = i + 1;
		if (ans.empty()) ans.push_back(i);
		else {
			for(int p = 0; p < sz; ++p){
				vector<int> cur = ans;
				cur.insert(cur.begin() + p, i);
				if (count_increasing(cur) <= k) tmp = cur;
				else break;
			}
			ans = tmp;
		}

		if (count_increasing(ans) == k){
			break;
		}
	}

	return ans;
}

Compilation message (stderr)

perm.cpp:4:34: error: 'vector' does not name a type
    4 | long long count_increasing(const vector<int>& v) {
      |                                  ^~~~~~
perm.cpp:4:40: error: expected ',' or '...' before '<' token
    4 | long long count_increasing(const vector<int>& v) {
      |                                        ^
perm.cpp: In function 'long long int count_increasing(int)':
perm.cpp:5:3: error: 'vector' was not declared in this scope
    5 |   vector<long long> dp(v.size() + 1, 0);
      |   ^~~~~~
perm.cpp:5:3: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from perm.h:1,
                 from perm.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from perm.h:1,
                 from perm.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
perm.cpp:5:10: error: expected primary-expression before 'long'
    5 |   vector<long long> dp(v.size() + 1, 0);
      |          ^~~~
perm.cpp:6:3: error: 'dp' was not declared in this scope
    6 |   dp[0] = 1;
      |   ^~
perm.cpp:7:16: error: 'v' was not declared in this scope
    7 |   for (int x : v)
      |                ^
perm.cpp:12:27: error: 'MX' was not declared in this scope
   12 |     dp[x+1] = min(dp[x+1],MX+1);
      |                           ^~
perm.cpp:12:15: error: 'min' was not declared in this scope; did you mean 'std::min'?
   12 |     dp[x+1] = min(dp[x+1],MX+1);
      |               ^~~
      |               std::min
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:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
perm.cpp:16:29: error: 'v' was not declared in this scope
   16 |   for (int i = 0; i <= (int)v.size(); i++){
      |                             ^
perm.cpp:18:24: error: 'MX' was not declared in this scope
   18 |    result = min(result,MX+1);
      |                        ^~
perm.cpp:18:13: error: 'min' was not declared in this scope; did you mean 'std::min'?
   18 |    result = min(result,MX+1);
      |             ^~~
      |             std::min
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:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:24:2: error: 'vector' was not declared in this scope
   24 |  vector <int> ans;
      |  ^~~~~~
perm.cpp:24:2: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from perm.h:1,
                 from perm.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from perm.h:1,
                 from perm.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
perm.cpp:24:10: error: expected primary-expression before 'int'
   24 |  vector <int> ans;
      |          ^~~
perm.cpp:27:11: error: expected primary-expression before 'int'
   27 |   vector <int> tmp;
      |           ^~~
perm.cpp:29:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |   if (ans.empty()) ans.push_back(i);
      |       ^~~
      |       abs
perm.cpp:32:12: error: expected primary-expression before 'int'
   32 |     vector<int> cur = ans;
      |            ^~~
perm.cpp:33:5: error: 'cur' was not declared in this scope
   33 |     cur.insert(cur.begin() + p, i);
      |     ^~~
perm.cpp:34:37: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   34 |     if (count_increasing(cur) <= k) tmp = cur;
      |                                     ^~~
      |                                     tm
perm.cpp:37:10: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   37 |    ans = tmp;
      |          ^~~
      |          tm
perm.cpp:40:24: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |   if (count_increasing(ans) == k){
      |                        ^~~
      |                        abs
perm.cpp:45:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |  return ans;
      |         ^~~
      |         abs