Submission #1145704

#TimeUsernameProblemLanguageResultExecution timeMemory
1145704AgageldiCheerleaders (info1cup20_cheerleaders)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 20005 #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define sz(s) (int)s.size() #define pii pair<int,int> //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll b[N], n, a[N], c[N], t, cnt = 0, ans = LLONG_MAX, fn[N], dp[3][N]; vector <int> v, ansv; int find(int x) { int sum = 0; while(x <= (1LL << n)) { sum += fn[x]; x += (x&(-x)); } return sum; } void upd(int x) { while(x > 0) { fn[x]++; x -= (x&(-x)); } } void rem(int x) { while(x > 0) { fn[x] = 0; x -= (x&(-x)); } } void check() { ll bal = 0, tr = 0; for(int i = 1; i <= (1LL << n); i++) { if(b[i] <= 1) { bal += (i - 1); if(!b[i]) tr = 1; else bal -= tr; continue; } int pp = find(b[i]); bal += pp; upd(b[i]); } for(int i = 1; i <= (1LL<<n) ;i++) { if(b[i] <= 1) continue; rem(b[i]); } if(ans > bal) ansv = v; ans = min(bal,ans); } void solve(int op,int sany,int san) { if(san > min(N,n*5)) return; check(); if(op == 2) { v.pb(2); cnt = 1; for(int i = 1; i <= (1LL<<n); i += 2) { c[cnt] = b[i]; cnt++; } for(int i = 2; i <= (1LL<<n); i += 2){ c[cnt] = b[i]; cnt++; } for(int i = 1; i <= (1LL<<n); i++) { b[i] = c[i]; } } if(op == 1) { v.pb(1); for(int i = 1; i <= (1LL << (n - 1)); i++) { swap(b[i],b[i + (1LL << (n - 1))]); } } solve(op % 2 + 1, 1, san + 1); if(sany < n - 1) solve(op, sany + 1, san + 1); } int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> n; for(int i = 1; i <= (1LL << n); i++) { cin >> a[i]; b[i] = a[i]; } solve(2,0,0); if(ans == INT_MAX) ans = 0; cout << ans << '\n'; if(!sz(ansv)) { cout <<"11"; } for(auto i:ansv) { cout << i; } cout << '\n'; }

Compilation message (stderr)

cheerleaders.cpp: In function 'void solve(int, int, int)':
cheerleaders.cpp:61:21: error: no matching function for call to 'min(int, long long int)'
   61 |         if(san > min(N,n*5)) return;
      |                  ~~~^~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from cheerleaders.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
cheerleaders.cpp:61:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   61 |         if(san > min(N,n*5)) return;
      |                  ~~~^~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from cheerleaders.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
cheerleaders.cpp:61:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   61 |         if(san > min(N,n*5)) return;
      |                  ~~~^~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from cheerleaders.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
cheerleaders.cpp:61:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   61 |         if(san > min(N,n*5)) return;
      |                  ~~~^~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from cheerleaders.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
cheerleaders.cpp:61:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   61 |         if(san > min(N,n*5)) return;
      |                  ~~~^~~~~~~