Submission #4034364
Source Code Expand
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
struct Grid{
int x,y,t;
};
using namespace std;
const int MAX_N = 2220;
int row,col;
ll rui[MAX_N][MAX_N];
ll ele[MAX_N][MAX_N];
void make_sum(int r,int l){
row=r;col=l;
for(int i=1;i<=row+1;i++)
for(int j=1;j<=col+1;j++)
rui[i][j] = ele[i][j] + rui[i-1][j] + rui[i][j-1] - rui[i-1][j-1];
}
ll ret_sum(int lx,int ly,int rx,int ry){//閉区間
if(lx>rx||ly>ry)return 0;
else return rui[rx][ry] - rui[lx-1][ry] - rui[rx][ly-1] + rui[lx-1][ly-1];
}
int main(){
int n,k;cin>>n>>k;
for(int i=0;i<n;i++){
int a,b;char c;
cin>>a>>b>>c;
if(c=='W')
b+=k;
a%=(2*k);
b%=(2*k);
ele[a+1][b+1]++;
}
ll ans=-1;
make_sum(2*k,2*k);
for(int i=1;i<=k;i++){
for(int j=1;j<=k;j++){
ll num = ret_sum(i,j,i+k-1,j+k-1)+ret_sum(i+k,j+k,2*k,2*k)+
ret_sum(1,1,i-1,j-1)+ret_sum(i+k,1,2*k,j-1)+ret_sum(1,j+k,i-1,2*k);
ans=max(ans,max(n-num,num));
}
}
cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Checker |
User |
shi |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
1324 Byte |
Status |
AC |
Exec Time |
165 ms |
Memory |
71936 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 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 |
2 ms |
2304 KB |
0_001.txt |
AC |
38 ms |
37120 KB |
0_002.txt |
AC |
2 ms |
2304 KB |
1_003.txt |
AC |
38 ms |
37120 KB |
1_004.txt |
AC |
2 ms |
2304 KB |
1_005.txt |
AC |
2 ms |
2304 KB |
1_006.txt |
AC |
2 ms |
2304 KB |
1_007.txt |
AC |
3 ms |
8448 KB |
1_008.txt |
AC |
39 ms |
39168 KB |
1_009.txt |
AC |
3 ms |
2304 KB |
1_010.txt |
AC |
3 ms |
2304 KB |
1_011.txt |
AC |
3 ms |
2304 KB |
1_012.txt |
AC |
5 ms |
8960 KB |
1_013.txt |
AC |
48 ms |
70144 KB |
1_014.txt |
AC |
115 ms |
2304 KB |
1_015.txt |
AC |
113 ms |
2304 KB |
1_016.txt |
AC |
118 ms |
2304 KB |
1_017.txt |
AC |
118 ms |
9088 KB |
1_018.txt |
AC |
165 ms |
71936 KB |
1_019.txt |
AC |
8 ms |
6912 KB |
1_020.txt |
AC |
8 ms |
6912 KB |
1_021.txt |
AC |
8 ms |
6912 KB |
1_022.txt |
AC |
8 ms |
6912 KB |
1_023.txt |
AC |
8 ms |
6912 KB |
1_024.txt |
AC |
8 ms |
6912 KB |
1_025.txt |
AC |
80 ms |
2304 KB |
1_026.txt |
AC |
135 ms |
41216 KB |
1_027.txt |
AC |
79 ms |
2304 KB |
1_028.txt |
AC |
117 ms |
37120 KB |
1_029.txt |
AC |
79 ms |
2432 KB |
1_030.txt |
AC |
126 ms |
70784 KB |