Submission #915137

#TimeUsernameProblemLanguageResultExecution timeMemory
915137Amirreza_FakhriPermutation (APIO22_perm)C++17
Compilation error
0 ms0 KiB
// In the name of the God #include <bits/stdc++.h> #include "perm.h" #define ll long long #define int long long #define pb push_back #define F first #define S second #define mp make_pair #define pii pair <int, int> #define smin(x, y) (x) = min((x), (y)) #define smax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(), (x).end() using namespace std; const int inf = 1e9+7; const int mod = 998244353; const int maxn = 2e5+5; vector <int> construct_permutation(int k) { vector <int> res; if (k == 1) { return res; } if (k == 2) { res.pb(0); return res; } if (k == 3) { res.pb(1), res.pb(0); return res; } res = construct_permutation(k/4); int l = res.size(); if ((k%4) == 0) { res.pb(l), res.pb(l+1); } else if ((k%4) == 1) { for (int &x : res) x++; res.pb(l+1), res.pb(l+2), res.pb(0); } else if ((k%4) == 2) { for (int &x : res) x++; res.pb(l+1), res.pb(0), res.pb(l+2); } else { bool flag; for (int x : res) { if (x <= 1) { flag = x; break; } } if (flag) { for (int &x : res) { if (x > 1) x++; } res.pb(l+1), res.pb(l+2), res.pb(2); } else { for (int &x : res) x += 2; res.pb(l+2), res.pb(1), res.pb(l+3), res.pb(0); } } return res; } // int32_t main() { // ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // return 0; // }

Compilation message (stderr)

perm.cpp:20:14: error: ambiguating new declaration of 'std::vector<long long int> construct_permutation(long long int)'
   20 | vector <int> construct_permutation(int k) {
      |              ^~~~~~~~~~~~~~~~~~~~~
In file included from perm.cpp:3:
perm.h:3:18: note: old declaration 'std::vector<int> construct_permutation(long long int)'
    3 | std::vector<int> construct_permutation(long long k);
      |                  ^~~~~~~~~~~~~~~~~~~~~
perm.cpp: In function 'std::vector<long long int> construct_permutation(long long int)':
perm.cpp:31:36: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   31 |     res = construct_permutation(k/4);
      |                                    ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from perm.cpp:2:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from perm.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~