Language: C++

#include <bits/stdc++.h>

using ll = long long;
using namespace std;

string bin_string(int size, int n) {
    string ret = "";
    for (int i = size - 1; i >= 0; i--) {
        int k = n >> i;
        if (k & 1) {
            ret += "1";
        } else {
            ret += "0";
        }
    }
    return ret;
}

int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> ch(h);
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        ch[i] = s;
    }
    ll ans = 1e9;
    for (int i = 0; i < pow(2, h - 1); i++) {
        string s = bin_string(h - 1, i);
        vector<int> starts;
        starts.emplace_back(0);
        for (int l = 0; l < h - 1; l++) {
            if (s[l] == '1') {
                starts.emplace_back(l + 1);
            }
        }
        int size = starts.size();
        vector<int> cur(size, 0);
        int count = size - 1;
        for (int l = 0; l < w; l++) {
            for (int n = 0; n < size; n++) {
                int sm = 0;
                int lim = (n == size - 1) ? h : starts[n + 1];
                for (int m = starts[n]; m < lim; m++) {
                    sm += int(ch[m][l] == '1');
                }
                cur[n] += sm;
                if (cur[n] > k) {
                    count++;
                    for (int mm = 0; mm < size; mm++) {
                        int ss = 0;
                        int mlim = (mm == size - 1) ? h : starts[mm + 1];
                        for (int mi = starts[mm]; mi < mlim; mi++) {
                            ss += int(ch[mi][l] == '1');
                        }
                        cur[mm] = ss;
                    }
                }
            }
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:18: error: no matching function for call to 'min(ll&, int&)'
   62 |         ans = min(ans, count);
      |               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:62:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   62 |         ans = min(ans, count);
      |               ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:62:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   62 |         ans = min(ans, count);
      |               ~~~^~~~~~~~~~~~