Submission #3051579


Source Code Expand

Copy
#include <iostream>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	#pragma omp parallel for num_threads(2)
	rep(i,k){
		int cnt[max(n,k)];
		rep(j,max(n,k))cnt[j]=0;
		rep(j,n){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		rep(j,k){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	rep(i,k)Max=max(Max,ans[i]);
	cout<<Max<<endl;
}

Submission Info

Submission Time
Task D - Checker
User autumn_eel
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1146 Byte
Status
Exec Time 2035 ms
Memory 2432 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
                     ^
./Main.cpp:36:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%s",&x[i],&y[i],s[i]);
                                   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
× 3
× 30
× 1
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 1 ms 256 KB
0_001.txt 3 ms 256 KB
0_002.txt 1 ms 256 KB
1_003.txt 3 ms 256 KB
1_004.txt 1 ms 256 KB
1_005.txt 1 ms 256 KB
1_006.txt 1 ms 256 KB
1_007.txt 1 ms 256 KB
1_008.txt 3 ms 256 KB
1_009.txt 1 ms 256 KB
1_010.txt 1 ms 256 KB
1_011.txt 1 ms 256 KB
1_012.txt 3 ms 256 KB
1_013.txt 10 ms 256 KB
1_014.txt 29 ms 2432 KB
1_015.txt 31 ms 2432 KB
1_016.txt 37 ms 2432 KB
1_017.txt 229 ms 2432 KB
1_018.txt 2035 ms 2432 KB
1_019.txt 9 ms 512 KB
1_020.txt 9 ms 512 KB
1_021.txt 9 ms 512 KB
1_022.txt 9 ms 512 KB
1_023.txt 9 ms 512 KB
1_024.txt 9 ms 512 KB
1_025.txt 38 ms 2432 KB
1_026.txt 1490 ms 2432 KB
1_027.txt 36 ms 2432 KB
1_028.txt 1312 ms 2432 KB
1_029.txt 40 ms 2432 KB
1_030.txt 1665 ms 2432 KB