Submission #2000826


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int VW, int VH> struct Ruisekiwa2D {
    int v[VH][VW];
    void set(int x, int y, int c) { v[y][x] = c; }
    void build() {
        rep(y, 0, VH) rep(x, 0, VW) {
            if (0 < y) v[y][x] += v[y - 1][x];
            if (0 < x) v[y][x] += v[y][x - 1];
            if (0 < y && 0 < x) v[y][x] -= v[y - 1][x - 1];
        }
    }
    int get(int sx, int sy, int tx, int ty) {
        assert(sx <= tx && sy <= ty);
        int rs = v[ty][tx];
        if (0 < sx) rs -= v[ty][sx - 1];
        if (0 < sy) rs -= v[sy - 1][tx];
        if (0 < sx && 0 < sy) rs += v[sy - 1][sx - 1];
        return rs;
    }
};
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/




int N, K, X[101010], Y[101010]; string C[101010];
//---------------------------------------------------------------------------------------------------
Ruisekiwa2D<4020, 4020> BR, WR;
int B[2010][2010], W[2010][2010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    int KK = K * 2;
    rep(i, 0, N) cin >> X[i] >> Y[i] >> C[i];

    rep(i, 0, N) {
        if (C[i] == "B") B[Y[i] % KK][X[i] % KK]++;
        else W[Y[i] % KK][X[i] % KK]++;
    }
    rep(y, 0, 2 * KK) rep(x, 0, 2 * KK) {
        BR.set(x, y, B[y % KK][x % KK]);
        WR.set(x, y, W[y % KK][x % KK]);
    }
    BR.build();
    WR.build();

    int ans = 0;
    rep(y, 0, KK) rep(x, 0, KK) {
        int b = BR.get(x, y, x + K - 1, y + K - 1) + BR.get(x + K, y + K, x + KK - 1, y + KK - 1);
        int w = WR.get(x + K, y, x + KK - 1, y + K - 1) + WR.get(x, y + K, x + K - 1, y + KK - 1);
        int sm = b + w;
        chmax(ans, sm);
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task D - Checker
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2948 Byte
Status AC
Exec Time 233 ms
Memory 164352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 31
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt
Case Name Status Exec Time Memory
0_000.txt AC 106 ms 130176 KB
0_001.txt AC 191 ms 130176 KB
0_002.txt AC 106 ms 130176 KB
1_003.txt AC 191 ms 130176 KB
1_004.txt AC 106 ms 128128 KB
1_005.txt AC 106 ms 130176 KB
1_006.txt AC 106 ms 130176 KB
1_007.txt AC 107 ms 130176 KB
1_008.txt AC 191 ms 130176 KB
1_009.txt AC 106 ms 130304 KB
1_010.txt AC 106 ms 130304 KB
1_011.txt AC 106 ms 130304 KB
1_012.txt AC 108 ms 133120 KB
1_013.txt AC 197 ms 157184 KB
1_014.txt AC 140 ms 135680 KB
1_015.txt AC 141 ms 135680 KB
1_016.txt AC 140 ms 135680 KB
1_017.txt AC 142 ms 138752 KB
1_018.txt AC 233 ms 164352 KB
1_019.txt AC 110 ms 132864 KB
1_020.txt AC 110 ms 132864 KB
1_021.txt AC 109 ms 129152 KB
1_022.txt AC 109 ms 129152 KB
1_023.txt AC 110 ms 133248 KB
1_024.txt AC 110 ms 133248 KB
1_025.txt AC 136 ms 135680 KB
1_026.txt AC 225 ms 141824 KB
1_027.txt AC 136 ms 135808 KB
1_028.txt AC 228 ms 163328 KB
1_029.txt AC 136 ms 135680 KB
1_030.txt AC 222 ms 135680 KB