Submission #2528456
Source Code Expand
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include <assert.h>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
// typedef std::pair<int,int> P;
struct edge { int to, cost; };
#define VMAX 100000
int K;
ll N, ans = 0;
ll X[100010], Y[100010];
ll W_[3010][3010], B_[3010][3010];
auto W = W_, B = B_;
std::string C[100010];
//yxyx
ll imos(int a, int b, int c, int d, int mode) {
int res = 0;
if (a>c || b>d)return 0;
if (mode == 0) {
if ((0 <= c && c<2 * K) || (0 <= d && d<2 * K))res += W[c][d];
if ((0 <= c && c<2 * K) || (0 <= b - 1 && b - 1<2 * K))res -= W[c][b - 1];
if ((0 <= a - 1 && a - 1<2 * K) || (0 <= d && d<2 * K))res -= W[a - 1][d];
if ((0 <= a - 1 && a - 1<2 * K) || (0 <= b - 1 && b - 1<2 * K))res += W[a - 1][b - 1];
}
else {
if ((0 <= c && c<2 * K) || (0 <= d && d<2 * K))res += B[c][d];
if ((0 <= c && c<2 * K) || (0 <= b - 1 && b - 1<2 * K))res -= B[c][b - 1];
if ((0 <= a - 1 && a - 1<2 * K) || (0 <= d && d<2 * K))res -= B[a - 1][d];
if ((0 <= a - 1 && a - 1<2 * K) || (0 <= b - 1 && b - 1<2 * K))res += B[a - 1][b - 1];
}
return res;
}
int main() {
std::ios_base::sync_with_stdio(false);
cin >> N >> K;
REP(i, N) {
cin >> X[i] >> Y[i] >> C[i];
X[i] %= 2 * K, Y[i] %= 2 * K;
if (C[i] == "W")W[Y[i]][X[i]] += 1;
else B[Y[i]][X[i]] += 1;
}
REP(i, 2 * K)REP(j, 2 * K) {
W[i][j + 1] += W[i][j];
B[i][j + 1] += B[i][j];
}
REP(i, 2 * K)REP(j, 2 * K) {
W[i + 1][j] += W[i][j];
B[i + 1][j] += B[i][j];
}
//for (size_t i = 0; i < 2 * K; i++)
//{
// for (size_t j = 0; j < 2 * K; j++)
// {
// cout << W[i][j] << ' ';
// }
// cout << endl;
//}
REP(i, K)REP(j, K)REP(k, 2) {
ll tans = 0;
tans += imos(0, 0, i - 1, j - 1, (k == 0 ? 0 : 1));
tans += imos(0, j, i - 1, j + K - 1, (k != 0 ? 0 : 1));
tans += imos(0, j + K, i - 1, 2 * K - 1, (k == 0 ? 0 : 1));
tans += imos(i, 0, i + K - 1, j - 1, (k != 0 ? 0 : 1));
tans += imos(i, j, i + K - 1, j + K - 1, (k == 0 ? 0 : 1));
tans += imos(i, j + K, i + K - 1, 2 * K - 1, (k != 0 ? 0 : 1));
tans += imos(K + i, 0, 2 * K - 1, j - 1, (k == 0 ? 0 : 1));
tans += imos(K + i, j, 2 * K - 1, j + K - 1, (k != 0 ? 0 : 1));
tans += imos(K + i, j + K, 2 * K - 1, 2 * K - 1, (k == 0 ? 0 : 1));
ans = max(tans, ans);
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Checker |
User |
eiya |
Language |
C++14 (Clang 3.8.0) |
Score |
0 |
Code Size |
3108 Byte |
Status |
WA |
Exec Time |
419 ms |
Memory |
102656 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 500 |
Status |
|
|
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 |
3 ms |
6528 KB |
0_001.txt |
AC |
162 ms |
101120 KB |
0_002.txt |
AC |
3 ms |
6528 KB |
1_003.txt |
AC |
162 ms |
101120 KB |
1_004.txt |
AC |
3 ms |
6528 KB |
1_005.txt |
AC |
3 ms |
6528 KB |
1_006.txt |
AC |
3 ms |
6528 KB |
1_007.txt |
AC |
6 ms |
16896 KB |
1_008.txt |
AC |
162 ms |
101248 KB |
1_009.txt |
AC |
5 ms |
6528 KB |
1_010.txt |
AC |
5 ms |
6528 KB |
1_011.txt |
AC |
5 ms |
6528 KB |
1_012.txt |
AC |
9 ms |
16896 KB |
1_013.txt |
AC |
165 ms |
101120 KB |
1_014.txt |
WA |
249 ms |
8064 KB |
1_015.txt |
WA |
248 ms |
8064 KB |
1_016.txt |
WA |
249 ms |
8064 KB |
1_017.txt |
WA |
255 ms |
18432 KB |
1_018.txt |
WA |
419 ms |
102656 KB |
1_019.txt |
AC |
20 ms |
17024 KB |
1_020.txt |
AC |
20 ms |
17024 KB |
1_021.txt |
AC |
20 ms |
17024 KB |
1_022.txt |
AC |
20 ms |
17024 KB |
1_023.txt |
AC |
20 ms |
17024 KB |
1_024.txt |
AC |
20 ms |
17024 KB |
1_025.txt |
WA |
185 ms |
8064 KB |
1_026.txt |
WA |
377 ms |
102656 KB |
1_027.txt |
WA |
188 ms |
8064 KB |
1_028.txt |
WA |
349 ms |
102656 KB |
1_029.txt |
AC |
187 ms |
8064 KB |
1_030.txt |
AC |
346 ms |
102656 KB |