Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

#define pb push_back
#define ll long long

using namespace std;

int origa[10][1000];
int h, w, k;

int getMinCuts(vector< vector<int> >& chl) {
    int curr = 0, rows = chl.size();
    int cuts = rows-1;
    while(curr < w) {
        int minw = 2000;
        for (int i=0;i<rows;i++) {
            int currsum = 0;
            if (curr) currsum = chl[i][curr-1];
            auto nextit = lower_bound(chl[i].begin(), chl[i].end(), currsum+k+1);
            if (nextit-chl[i].begin() == curr) return 1000000;
            minw = min(minw, nextit - chl[i].begin());
        }
        curr = minw;
        if (curr != w) cuts++;
    }
    return cuts;
}

int createNewPartition(vector< vector<int> >& currPartition, int row) {
    if (row == h) {
        return getMinCuts(currPartition);
    }
    vector<int> roww(w, 0);
    currPartition.pb(roww);
    int mincuts = 40000;
    while(row < h) {
        for (int i=0;i<w;i++) currPartition.back()[i] += origa[row][i];
        mincuts = min(mincuts, createNewPartition(currPartition, ++row));
    }
    currPartition.pop_back();
    return mincuts;
}

int main() {
    cin >> h >> w >> k;
    for (int i=0;i<h;i++) {
        string s;
        cin >> s;
        for (int j=0;j<w;j++) origa[i][j] = s.at(j) - '0';
    }
    for(int i=0;i<h;i++) {
        for(int j=1;j<w;j++) origa[i][j] += origa[i][j-1];
    }

    vector< vector<int> > currP;
    cout << createNewPartition(currP, 0) << "\n";

    return 0;
}


Compiler output:
a.cc: In function 'int getMinCuts(std::vector<std::vector<int> >&)':
a.cc:24:23: error: no matching function for call to 'min(int&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   24 |             minw = min(minw, nextit - chl[i].begin());
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:24:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   24 |             minw = min(minw, nextit - chl[i].begin());
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:3:
/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:24:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |             minw = min(minw, nextit - chl[i].begin());
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~