Submission #2531435
Source Code Expand
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n,k;
cin >> n >> k;
int x[n],y[n];
rep(i,n){
string c;
cin >> x[i] >> y[i] >> c;
// 黒で塗る基準に変換
if(c == "W") x[i] += k;
// 「市松模様の基準セル」(白正方形の左下セル)で市松模様を分類する
// セルを塗ることができる塗り方の「市松模様の基準セル」はK*Kの正方形となるが、
// その正方形の左下のセルに情報を変換
x[i] += 2*k - (k-1);
y[i] += 2*k - (k-1);
x[i] %= 2*k;
y[i] %= 2*k;
}
int a[2*k][2*k];
rep(i,2*k) rep(j,2*k) a[i][j] = 0;
rep(i,n){
int r = y[i], c = x[i];
a[r][c]++;
a[(r+k) % (2*k)][c]--;
if(r+k>=2*k) a[0][c]++;
a[r][(c+k) % (2*k)]--;
if(c+k>=2*k) a[r][0]++;
a[(r+k) % (2*k)][(c+k) % (2*k)]++;
if(r+k>=2*k || c+k>=2*k) a[0][0]++;
if(r+k>=2*k) a[r-k][0]--;
if(c+k>=2*k) a[0][c-k]--;
}
int s[2*k][2*k];
rep(i,2*k) rep(j,2*k) s[i][j] = (i==0 || j==0) ? a[i][j] : 0;
rep(i,2*k) rep(j,2*k-1) s[i][j+1] += s[i][j];
rep(j,2*k) rep(i,2*k-1) s[i+1][j] += s[i][j];
int ans = 0;
rep(i,2*k) rep(j,2*k) ans = max(ans,s[i][j]);
cout << ans << endl;
}
Submission Info
Submission Time |
|
Task |
D - Checker |
User |
misora192 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1496 Byte |
Status |
WA |
Exec Time |
80 ms |
Memory |
32256 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 |
1 ms |
256 KB |
0_001.txt |
WA |
37 ms |
31488 KB |
0_002.txt |
AC |
1 ms |
256 KB |
1_003.txt |
AC |
37 ms |
31488 KB |
1_004.txt |
AC |
2 ms |
256 KB |
1_005.txt |
AC |
1 ms |
256 KB |
1_006.txt |
WA |
1 ms |
256 KB |
1_007.txt |
WA |
2 ms |
512 KB |
1_008.txt |
AC |
37 ms |
31488 KB |
1_009.txt |
WA |
2 ms |
256 KB |
1_010.txt |
WA |
2 ms |
256 KB |
1_011.txt |
WA |
2 ms |
256 KB |
1_012.txt |
WA |
2 ms |
640 KB |
1_013.txt |
WA |
39 ms |
31488 KB |
1_014.txt |
WA |
44 ms |
1024 KB |
1_015.txt |
WA |
44 ms |
1024 KB |
1_016.txt |
WA |
46 ms |
1024 KB |
1_017.txt |
WA |
44 ms |
1408 KB |
1_018.txt |
WA |
80 ms |
32256 KB |
1_019.txt |
WA |
5 ms |
640 KB |
1_020.txt |
WA |
5 ms |
640 KB |
1_021.txt |
WA |
5 ms |
640 KB |
1_022.txt |
WA |
5 ms |
640 KB |
1_023.txt |
WA |
5 ms |
640 KB |
1_024.txt |
WA |
5 ms |
640 KB |
1_025.txt |
WA |
40 ms |
1024 KB |
1_026.txt |
WA |
77 ms |
32256 KB |
1_027.txt |
WA |
40 ms |
1024 KB |
1_028.txt |
WA |
76 ms |
32256 KB |
1_029.txt |
WA |
40 ms |
1024 KB |
1_030.txt |
WA |
76 ms |
32256 KB |