Language: C++

#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX],finv[MAX],inv[MAX];
typedef vector<vector<int> > Graph;

int main(){
    int h,w,k;cin>>h>>w>>k;
    ll ans=INF;
    vector<string> s(h);
    for(int i=0;i<h;i++) cin>>s[i];
    for(int bit=0;bit<(1<<h-1);bit++){
        int res=0;
        vector<int> cut(h-1,0);
        for(int j=0;j<h-1;j++){
            if(bit>>j&1){
                res++;
                cut[j]=1;
            }
        }
        vector<int> c(res+1,0);
        for(int i=0;i<w;i++){
            int flag=0;
            int idx=0;
            vector<int> c_d(res+1,0);
            for(int j=0;j<h;j++){
                if(j!=0){
                    if(cut[j-1]==1) idx++;
                }
                if(s[j][i]=='1'){
                    c[idx]++;
                    c_d[idx]++;
                    
                }
                if(c[idx]>k){
                    if(flag) res=INF;
                    res++;
                    for(int l=0;l<res+1;l++){
                        c[l]=c_d[l];
                    }
                    flag=1;
                }
            }
        }
        ans=min(ans,res);
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:16: error: no matching function for call to 'min(ll&, int&)'
   58 |         ans=min(ans,res);
      |             ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 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:58:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   58 |         ans=min(ans,res);
      |             ~~~^~~~~~~~~
/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:58:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   58 |         ans=min(ans,res);
      |             ~~~^~~~~~~~~