Submission #3381109


Source Code Expand

#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

int s[6000][6000];
int b[2000][2000];


int main(){
    int N,K;

    cin >> N >> K;

    REP(i,6000)REP(j,6000)s[i][j] = 0;
    REP(i,2000)REP(j,2000)b[i][j] = 0;

    REP(i,N){
        ll x,y;
        char c;
        cin >> x >> y >> c;

        if(c == 'W') y += K;
        b[x%(2*K)][y%(2*K)] += 1;
    }
    REP(i,2*K)REP(j,2*K){
        if(b[i][j] == 0)continue;

        REP(k,2)REP(l,2){
            s[i+1+2*K*k][j+1+2*K*l] += b[i][j];
            s[i+K+1+2*K*k][j+K+1+2*K*l] += b[i][j];
            s[i+K+1+2*K*k][j+1+2*K*l] -= b[i][j];
            s[i+1+2*K*k][j+K+1+2*K*l] -= b[i][j];
        }
    }

    REP(i,6000)FOR(j,1,6000)s[i][j] += s[i][j-1];
    REP(i,6000)FOR(j,1,6000)s[j][i] += s[j-1][i];

    ll ans = 0;
    FOR(i,1,5000)FOR(j,1,5000){
        ll tmp = 0;
        tmp += s[i][j];
        tmp += s[i+K][j+K];
        ans = max(ans,tmp);
    }

    cout << ans << endl;
}

Submission Info

Submission Time
Task D - Checker
User taka99
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1231 Byte
Status AC
Exec Time 374 ms
Memory 156544 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 294 ms 156544 KB
0_001.txt AC 277 ms 156544 KB
0_002.txt AC 273 ms 156544 KB
1_003.txt AC 277 ms 156544 KB
1_004.txt AC 274 ms 156544 KB
1_005.txt AC 273 ms 156544 KB
1_006.txt AC 274 ms 156544 KB
1_007.txt AC 274 ms 156544 KB
1_008.txt AC 277 ms 156544 KB
1_009.txt AC 275 ms 156544 KB
1_010.txt AC 274 ms 156544 KB
1_011.txt AC 274 ms 156544 KB
1_012.txt AC 275 ms 156544 KB
1_013.txt AC 277 ms 156544 KB
1_014.txt AC 361 ms 156544 KB
1_015.txt AC 362 ms 156544 KB
1_016.txt AC 358 ms 156544 KB
1_017.txt AC 364 ms 156544 KB
1_018.txt AC 374 ms 156544 KB
1_019.txt AC 275 ms 156544 KB
1_020.txt AC 275 ms 156544 KB
1_021.txt AC 275 ms 156544 KB
1_022.txt AC 276 ms 156544 KB
1_023.txt AC 276 ms 156544 KB
1_024.txt AC 275 ms 156544 KB
1_025.txt AC 334 ms 156544 KB
1_026.txt AC 349 ms 156544 KB
1_027.txt AC 337 ms 156544 KB
1_028.txt AC 339 ms 156544 KB
1_029.txt AC 336 ms 156544 KB
1_030.txt AC 339 ms 156544 KB