Language: C++

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n,k;cin>>n>>k;
    vector<vector<ll> > mat(2010,vector<ll>(2010,0)),wmat(2010,vector<ll>(2010,0)); 
    vector<P> bl,wh;
    for(int i=0;i<n;i++){
        ll x,y;char c;
        cin>>x>>y>>c;
        P p=P(x,y);
        if(c=='B') bl.push_back(p);
        else wh.push_back(p);
    }
    //mat[i][j]:= i,jを左下にしたとき、得られる黒の数
    for(int i=0;i<(int)bl.size();i++){
        ll x=bl[i].first,y=bl[i].second;
        mat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
        mat[x%(2*k)+1][max(0,y%(2*k)+1-k)]--;
        mat[max(0,x%(2*k)+1-k)][y%(2*k)+1]--;
        mat[x%(2*k)+1][y%(2*k)+1]++;
    }
    for(int i=0;i<2010;i++){
        for(int j=0;j<2010;j++){
            if(i>0 && j>0) mat[i][j]+=mat[i-1][j]+mat[i][j-1]-mat[i-1][j-1];
            else if(i>0) mat[i][j]+=mat[i-1][j];
            else if(j>0) mat[i][j]+=mat[i][j-1];
        }
    }
    //wmat[i][j]:=i,jを左下にしたとき、失われる白の数
    for(int i=0;i<(int)wh.size();i++){
        ll x=wh[i].first,y=wh[i].second;
        wmat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
        wmat[x%(2*k)+1][max(0,y%(2*k)+1-k)]--;
        wmat[max(0,x%(2*k)+1-k)][y%(2*k)+1]--;
        wmat[x%(2*k)+1][y%(2*k)+1]++;
    }
    for(int i=0;i<2010;i++){
        for(int j=0;j<2010;j++){
            if(i>0 && j>0) wmat[i][j]+=wmat[i-1][j]+wmat[i][j-1]-wmat[i-1][j-1];
            else if(i>0) wmat[i][j]+=wmat[i-1][j];
            else if(j>0) wmat[i][j]+=wmat[i][j-1];
        }
    }
    int wnum=wh.size();
    int res=0;
    for(int i=0;i<2010;i++){
        for(int j=0;j<2010;j++){
            int tmp=mat[i][j]+(wnum-wmat[i][j]);
            res=max(res,tmp);
        }
    }
    cout<<res<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:16: error: no matching function for call to 'max(int, ll)'
   32 |         mat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |             ~~~^~~~~~~~~~~~~~~
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: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++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:32:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   32 |         mat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |             ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:32:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |         mat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |             ~~~^~~~~~~~~~~~~~~
a.cc:32:36: error: no matching function for call to 'max(int, ll)'
   32 |         mat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |                                 ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:32:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   32 |         mat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |                                 ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:32:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |         mat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |                                 ~~~^~~~~~~~~~~~~~~
a.cc:33:27: error: no matching function for call to 'max(int, ll)'
   33 |         mat[x%(2*k)+1][max(0,y%(2*k)+1-k)]--;
      |                        ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:33:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   33 |         mat[x%(2*k)+1][max(0,y%(2*k)+1-k)]--;
      |                        ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:33:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |         mat[x%(2*k)+1][max(0,y%(2*k)+1-k)]--;
      |                        ~~~^~~~~~~~~~~~~~~
a.cc:34:16: error: no matching function for call to 'max(int, ll)'
   34 |         mat[max(0,x%(2*k)+1-k)][y%(2*k)+1]--;
      |             ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:34:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   34 |         mat[max(0,x%(2*k)+1-k)][y%(2*k)+1]--;
      |             ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:34:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |         mat[max(0,x%(2*k)+1-k)][y%(2*k)+1]--;
      |             ~~~^~~~~~~~~~~~~~~
a.cc:47:17: error: no matching function for call to 'max(int, ll)'
   47 |         wmat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |              ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:47:17: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   47 |         wmat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |              ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:47:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |         wmat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |              ~~~^~~~~~~~~~~~~~~
a.cc:47:37: error: no matching function for call to 'max(int, ll)'
   47 |         wmat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |                                  ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:47:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   47 |         wmat[max(0,x%(2*k)+1-k)][max(0,y%(2*k)+1-k)]++;
      |                                  ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, c