Language: C++

#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>

typedef long long ll;
using std::vector;
using std::string;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

template<typename T>
struct CumSum2D {
    int xnum, ynum;
    vector<vector<T>> data;
    vector<vector<T>> cumsum;
    
    CumSum2D(int xnum, int ynum) : xnum(xnum), ynum(ynum) {
        ndarray(data, xnum+1, ynum+1);
        ndarray(cumsum, xnum+1, ynum+1);
    }
    
    int add(int x, int y, T value) {
        //x,y 1~_num
        if (x > xnum || y > ynum) return -1;
        data[x][y] += value;
        return 0;
    }
    
    int add_imos(int startx, int starty, int endx, int endy) {
        //x,y 1~_num
        if (add(endx, endy, (T) 1) == 1) return -1;
        if (add(startx-1, endy, (T) 1) == -1) return -1;
        if (add(endx, starty-1, (T) 1) == -1) return -1;
        if (add(startx-1, starty-1, (T) 1) == 1) return -1;
        return 0;
    }
    
    void build() {
        for (int i = 0; i < xnum; i++) {
            for (int j = 0; j < ynum; j++) {
                cumsum[i+1][j+1] = data[i+1][j+1] + cumsum[i+1][j] + cumsum[i][j+1] - cumsum[i][j];
            }
        }
    }
    
    T get(int startx, int starty, int endx, int endy) {
        //x,y 1~_num
        //(startx, starty) ~ (endx, endy)の範囲のdataの和を返す
        return (cumsum[endx][endy] - cumsum[endx][starty-1] - cumsum[startx-1][endy] - cumsum[startx-1][starty-1]);
    }
    
    void print() {
        for (auto vec : cumsum) {
            for (auto val : vec) {
                std::cout << val << " ";
            }
            std::cout << std::endl;
        }
    }
};

//////////////////////////////////////

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    
    int N, K;
    std::cin >> N >> K;
    int K2 = K * 2;
    CumSum2D<int> cs(K2, K2);
    
    //Wは+KでBに変換可能
    //mod 2*Kを取って良い
    
    //1.叶えられる希望の最大値 = 必要な塗り方の重なりの最大値：imos法
    //塗り方は黒の塊の左下位置Bを代表にとる
    //一つの希望に対し、黒は最大5つの範囲が存在するが、Bは2つの範囲のいずれかに属する
    //これを場合分けして各範囲で足す手もあるが、大変
    
    //2.Bを決め、その場合に含まれる希望の数を累積和で数える
    //場合分けの代わりに、もう一つの範囲分にもaddしておく
    //Bは(0,0)~(K-1,K-1)のみ考えれば十分
    //この方が場合分けが少なくて楽
    
    for (int i = 0; i < N; i++) {
        int x, y;
        std::cin >> x >> y;
        char c;
        std::cin >> c;
        if (c == 'W') x += K;
        x = x % K2;
        y = y % K;
        if(y >= K) {
            y -= K;
            x = (x + K) % K2;
        }
        if (cs.add(x, y, 1) == -1) return -1;
        if (cs.add((x+K) % K2, y+K, 1) == -1) return -1;
    }
    cs.build();
    //cs.print();
    
    int ans = 0;
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            auto b = cs.get(i+1, j+1, i+K+1, j+K+1);
            ans = std::max({ans, b, N-b});
            if (ans == N) {
                std::cout << ans << std::endl;
                return 0;
            }
        }
    }
    std::cout << ans << std::endl;
    
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:120:27: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
  120 |             ans = std::max({ans, b, N-b});
      |                   ~~~~~~~~^~~~~~~~~~~~~~~
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: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:   candidate expects 2 arguments, 1 provided
/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, 1 provided