Submission #4014554


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;
        x %= 2 * K;
        y %= 2 * K;
        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 2010 Byte
Status WA
Exec Time 165 ms
Memory 16256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 18
WA × 13
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 43 ms 16128 KB
0_002.txt AC 9 ms 16128 KB
1_003.txt AC 43 ms 16128 KB
1_004.txt AC 10 ms 16128 KB
1_005.txt AC 10 ms 16128 KB
1_006.txt AC 10 ms 16256 KB
1_007.txt AC 9 ms 16128 KB
1_008.txt AC 44 ms 16128 KB
1_009.txt AC 10 ms 16128 KB
1_010.txt AC 10 ms 16128 KB
1_011.txt WA 10 ms 16128 KB
1_012.txt WA 10 ms 16128 KB
1_013.txt WA 44 ms 16128 KB
1_014.txt AC 106 ms 16128 KB
1_015.txt WA 109 ms 16128 KB
1_016.txt WA 111 ms 16128 KB
1_017.txt WA 113 ms 16128 KB
1_018.txt WA 165 ms 16128 KB
1_019.txt WA 16 ms 16128 KB
1_020.txt WA 16 ms 16128 KB
1_021.txt WA 15 ms 16128 KB
1_022.txt WA 16 ms 16128 KB
1_023.txt AC 16 ms 16128 KB
1_024.txt AC 16 ms 16128 KB
1_025.txt AC 84 ms 16128 KB
1_026.txt AC 130 ms 16128 KB
1_027.txt AC 91 ms 16128 KB
1_028.txt AC 125 ms 16128 KB
1_029.txt WA 89 ms 16128 KB
1_030.txt WA 124 ms 16128 KB