Submission #621172

# Submission time Handle Problem Language Result Execution time Memory
621172 2022-08-03T13:26:08 Z aworue Permutation (APIO22_perm) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <perm.h>
using ll = long long;
//#define int ll
using namespace std;

#define sz(x) (int)(x).size()
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, l, r) for(int i = l; i >= r; i--)
#define fi first
#define se second
#define mod 998244353

#define db(x) cerr << __LINE__ << " " << #x << " " << x << "\n"
using vi = vector<int>;
using pi = pair<int, int>;

const int N = 200005;
const ll inf = 3e18;

vi construct_permutation(int k){
	if(k == 1) return {};
	if(k == 2) return {0};
	if(k == 3) return {1, 0};
	auto res = construct_permutation((int)(k / 4));
	int s = sz(res);
	if(k % 4 == 0){
		res.push_back(s);
		res.push_back(s + 1);
		return res;
	}
	if(k % 4 == 1){
		res.push_back(s);
		res.push_back(s + 1);
		res.push_back(-1);
		for(auto &x : res) x++;
		return res;
	}
	if(k % 4 == 2){
		res.push_back(s);
		res.push_back(-1);
		res.push_back(s + 1);
		for(auto &x : res) x++;
		return res;
	}
	auto z = res;
	res.push_back(s);
	res.push_back(s + 1);
	for(auto &x : res) if(x > 1) x++;
	res.push_back(2);
	vi f(sz(res), 1);
	int sum = 1;	
	foru(i, 1, sz(res) - 1){
		foru(j, 0, i - 1){
			if(res[j] < res[i]) f[i] += f[j];
			f[i] = min(f[i], inf);
		}
		sum = min(sum + f[i], inf);
	}
	if(sum == k) return res;
	for(auto &x : z) x += 2;
	z.push_back(s + 2);
	z.push_back(1);
	z.push_back(s + 3);
	z.push_back(0);
	return z;
}

/*void solve(){
	int q; cin >> q;
	while(q--){
		int k; cin >> k;
		for(auto x : construct_permutation(k)){
			cout << x << " ";
		}
		cout << "\n";
	}
}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int t = 1; // cin >> t;
	while(t--){
		solve();
	}
}*/

Compilation message

perm.cpp: In function 'vi construct_permutation(int)':
perm.cpp:56:24: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, const ll&)'
   56 |    f[i] = min(f[i], inf);
      |                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from perm.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
perm.cpp:56:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   56 |    f[i] = min(f[i], inf);
      |                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from perm.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
perm.cpp:56:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   56 |    f[i] = min(f[i], inf);
      |                        ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
perm.cpp:56:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |    f[i] = min(f[i], inf);
      |                        ^
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:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
perm.cpp:56:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |    f[i] = min(f[i], inf);
      |                        ^
perm.cpp:58:28: error: no matching function for call to 'min(int, const ll&)'
   58 |   sum = min(sum + f[i], inf);
      |                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from perm.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
perm.cpp:58:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   58 |   sum = min(sum + f[i], inf);
      |                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from perm.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
perm.cpp:58:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   58 |   sum = min(sum + f[i], inf);
      |                            ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
perm.cpp:58:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |   sum = min(sum + f[i], inf);
      |                            ^
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:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
perm.cpp:58:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |   sum = min(sum + f[i], inf);
      |                            ^