Submission #4014540


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
const ll MOD = 1e9 + 7;

ll N, K;
//ll imos[1010][2010];
vector<vector<ll>> imos;

void sla(ll &x, ll &y){
    x -= K;
    if(y >= K) y -= K;
    else y += K;
}

void to_range(ll &x, ll &y){
    if(K <= x) sla(x, y);
}

int main(){
    cin >> N >> K;
    imos = decltype(imos)(1010, vector<ll>(2010));
    for(ll HOPE = 0; HOPE < N; HOPE++){
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W'){
            if(x >= K) x -= K;
            else x += K;
        }
        to_range(x, y);
        ll fx = x + 1;
        ll fy = y + 1;
        to_range(fx, fy);
        imos[fx][fy]++;
        vector<P> xs = {P(fx, 1)};
        ll fxm = fx + K;
        if(fxm > K){
            imos[0][fy]++;
            xs.push_back(P(0, 1));
            fxm %= K;
        }
        imos[fxm][fy]--;
        xs.push_back(P(fxm, -1));
        ll fym = fy + K;
        if(fym > 2 * K){
            for(const P &p : xs) imos[p.first][0] += p.second;
            fym %= 2 * K;
        }
        for(const P &p : xs) imos[p.first][fym] -= p.second;
#if 0
        //for(ll x = 0; x <= K; x++) for(ll y = 0; y <= 2 * K; y++) imos[x + 1][y] += imos[x][y];
        //for(ll y = 0; y <= 2 * K; y++) for(ll x = 0; x <= K; x++) imos[x][y + 1] += imos[x][y];
        for(ll i = 2 * K; i >= 0; i--){
            for(ll j = 0; j <= K; j++) cout << imos[j][i] << ' ';
            cout << endl;
        }
        cout << "\n=====================\n";
#endif
    }
    for(ll x = 0; x <= K; x++) for(ll y = 0; y <= 2 * K; y++) imos[x + 1][y] += imos[x][y];
    for(ll y = 0; y <= 2 * K; y++) for(ll x = 0; x <= K; x++) imos[x][y + 1] += imos[x][y];
    ll ans = 0;
    for(ll x = 0; x <= K; x++) for(ll y = 0; y <= 2 * K; y++) ans = max(ans, imos[x][y]);
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Checker
User kcvlex
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1968 Byte
Status RE
Exec Time 113 ms
Memory 16128 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 5
WA × 4
RE × 22
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 9 ms 16128 KB
0_001.txt AC 42 ms 16128 KB
0_002.txt AC 9 ms 16128 KB
1_003.txt RE 107 ms 16128 KB
1_004.txt RE 108 ms 16128 KB
1_005.txt RE 106 ms 16128 KB
1_006.txt RE 106 ms 16128 KB
1_007.txt RE 105 ms 16128 KB
1_008.txt RE 108 ms 16128 KB
1_009.txt RE 109 ms 16128 KB
1_010.txt RE 108 ms 16128 KB
1_011.txt RE 108 ms 16128 KB
1_012.txt RE 110 ms 16128 KB
1_013.txt RE 110 ms 16128 KB
1_014.txt RE 107 ms 16128 KB
1_015.txt RE 106 ms 16128 KB
1_016.txt RE 106 ms 16128 KB
1_017.txt RE 113 ms 16128 KB
1_018.txt RE 108 ms 16128 KB
1_019.txt WA 15 ms 16128 KB
1_020.txt WA 15 ms 16128 KB
1_021.txt WA 15 ms 16128 KB
1_022.txt WA 15 ms 16128 KB
1_023.txt AC 15 ms 16128 KB
1_024.txt AC 15 ms 16128 KB
1_025.txt RE 106 ms 16128 KB
1_026.txt RE 107 ms 16128 KB
1_027.txt RE 106 ms 16128 KB
1_028.txt RE 107 ms 16128 KB
1_029.txt RE 108 ms 16128 KB
1_030.txt RE 108 ms 16128 KB