Submission #3054102


Source Code Expand

Copy
cat<<EOF>Source.cpp

extern "C"{
int printf (const char *__restrict __format, ...);
int scanf (const char *__restrict __format, ...) ;
}
int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x/k&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x%k]--;
		}
		else{
			cnt[k-x%k]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x%k]++;
		}
		else{
			cnt[0]++;
			cnt[k-x%k]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
	}
	int Max=0;
	#pragma omp parallel for num_threads(2)
	for(int i=0;i<k;i++){
		int d=max(n,k);
		int cnt[d];
		for(int j=0;j<d;j++)cnt[j]=0;
		for(int j=0;j<n;j++){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,y[j],0);
				}
				else{
					add(cnt,y[j],1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,y[j],1);
				}
				else{
					add(cnt,y[j],0);
				}
			}
		}
		for(int j=0;j<k;j++){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	for(int i=0;i<k;i++)Max=max(Max,ans[i]);
	printf("%d\n",Max);
}
EOF
clang++ -Ofast Source.cpp -o Source -fopenmp -std=c++11
./Source

Submission Info

Submission Time
Task D - Checker
User autumn_eel
Language Bash (GNU bash v4.3.11)
Score 500
Code Size 1257 Byte
Status
Exec Time 1563 ms
Memory 11256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt, 0_002.txt
All 500 / 500 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 90 ms 10748 KB
0_001.txt 91 ms 10748 KB
0_002.txt 91 ms 10740 KB
1_003.txt 92 ms 10740 KB
1_004.txt 90 ms 10740 KB
1_005.txt 91 ms 10752 KB
1_006.txt 89 ms 10752 KB
1_007.txt 90 ms 10752 KB
1_008.txt 93 ms 10748 KB
1_009.txt 90 ms 10752 KB
1_010.txt 91 ms 10744 KB
1_011.txt 90 ms 11256 KB
1_012.txt 90 ms 10736 KB
1_013.txt 103 ms 10748 KB
1_014.txt 119 ms 10744 KB
1_015.txt 118 ms 10744 KB
1_016.txt 125 ms 10740 KB
1_017.txt 261 ms 10744 KB
1_018.txt 1563 ms 10752 KB
1_019.txt 99 ms 10748 KB
1_020.txt 100 ms 10744 KB
1_021.txt 99 ms 10740 KB
1_022.txt 104 ms 10748 KB
1_023.txt 104 ms 10744 KB
1_024.txt 100 ms 10740 KB
1_025.txt 129 ms 10744 KB
1_026.txt 1415 ms 10740 KB
1_027.txt 128 ms 10756 KB
1_028.txt 1389 ms 10748 KB
1_029.txt 123 ms 10748 KB
1_030.txt 1339 ms 10744 KB