Submission #582067

#TimeUsernameProblemLanguageResultExecution timeMemory
582067amunduzbaevBoarding Passes (BOI22_passes)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #define ar array typedef int64_t ll; #define int long long const int N = 1e4 + 5; const int G = 10; int dp[1 << G], pref[N], suff[N]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); string s; cin>>s; int n = s.size(), g = 0; for(int i=0;i<n;i++){ g = max(g, s[i] - 'A' + 1); } //~ cout<<s<<endl; memset(dp, 63, sizeof dp); dp[0] = 0; for(int mask=0;mask < (1 << g);mask++){ //~ for(int i=0;i<g;i++) cout<<(mask >> i & 1); //~ cout<<"\n"; //~ cout<<dp[mask]<<"\n"; for(int j=0;j<g;j++){ if(mask >> j & 1) continue; memset(pref, 0, sizeof pref); memset(suff, 0, sizeof suff); int cnt = 0; for(int k=0;k<n;k++){ if(k) pref[k] += pref[k-1]; if(s[k] - 'A' == j){ pref[k] += cnt; cnt++; } if(mask >> (s[k] - 'A') & 1) cnt += 2; } cnt = 0; for(int i=n-1;~i;i--){ if(i + 1 < n) suff[i] += suff[i + 1]; if(s[i] - 'A' == j){ suff[i] += cnt; cnt++; } if(mask >> (s[i] - 'A') & 1) cnt += 2; } int res = min(pref[n-1], suff[0]); for(int i=1;i<n;i++){ res = min(res, pref[i-1] + suff[i]); } dp[mask | (1 << j)] = min(dp[mask | (1 << j)], dp[mask] + res); } } double res = dp[(1 << g) - 1] / 2.; cout<<res<<"\n"; }

Compilation message (stderr)

passes.cpp: In function 'int main()':
passes.cpp:18:28: error: no matching function for call to 'max(long long int&, int)'
   18 |   g = max(g, s[i] - 'A' + 1);
      |                            ^
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 passes.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
passes.cpp:18:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |   g = max(g, s[i] - 'A' + 1);
      |                            ^
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 passes.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
passes.cpp:18:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |   g = max(g, s[i] - 'A' + 1);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from passes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
passes.cpp:18:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |   g = max(g, s[i] - 'A' + 1);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from passes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
passes.cpp:18:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |   g = max(g, s[i] - 'A' + 1);
      |                            ^