Submission #1311360

#TimeUsernameProblemLanguageResultExecution timeMemory
1311360hackjsPainting Walls (APIO20_paint)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ull unsigned long long #define ld long double #define pb push_back #define str string #define sz(a) (int) a.size() #define pii pair<int,int> #define vi vector<int> #define rall(a) a.rbegin(), a.rend() #define all(a) a.begin(), a.end() #define mp(a,b) make_pair(a,b) #define fi first #define se second #define debug(a) cout << #a << " = " << a << endl; #define fff cout << "----------------------------------------" <<endl; // #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> using namespace std; // using namespace __gnu_pbds; mt19937 rng(47); int randint(int l, int r){ return uniform_int_distribution<int>(l, r)(rng); } int minimumInstructions(int n,int m,int k, vi c, vi a, vector<vi> b){ vector<unordered_map<int,int>> DP(n); vi F(n, 0); vector<vi> val(k); vector<unordered_map<int,bool>> vv(k); for(int i = 0;i < m;++i){ for(int j : b[i]){ val[j].pb(i); vv[j][i] = true; } } for(int j : val[c[n-1]]) { DP[n-1][j] = 1; } for(int i = n-2;i >= 0;--i){ int x = 0; for(int j : val[c[i+1]]){ int th = (j - 1 + m) % m; if(vv[c[i]][th]){ x = max(x, DP[i][th] = max(DP[i][th], DP[i+1][j] + 1)); } } for(int j : val[c[i]]){ x = max(x, DP[i][j] = max(DP[i][j], 1ll)); } F[i] = x; } int ans = 0; int l = 0; while(l < n){ int x =F[l]; x = min(x, m); ++ans; l += x; if(x == 0){ return -1; } } return ans; }

Compilation message (stderr)

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:52:38: error: no matching function for call to 'max(std::unordered_map<int, int>::mapped_type&, long long int)'
   52 |             x = max(x, DP[i][j] = max(DP[i][j], 1ll));
      |                                   ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from paint.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
paint.cpp:52:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   52 |             x = max(x, DP[i][j] = max(DP[i][j], 1ll));
      |                                   ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
paint.cpp:52:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   52 |             x = max(x, DP[i][j] = max(DP[i][j], 1ll));
      |                                   ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
paint.cpp:52:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |             x = max(x, DP[i][j] = max(DP[i][j], 1ll));
      |                                   ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
paint.cpp:52:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |             x = max(x, DP[i][j] = max(DP[i][j], 1ll));
      |                                   ~~~^~~~~~~~~~~~~~~