Submission #3052744


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],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);
	for(int i=0;i<n;i++){
		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)
	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,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,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
g++ -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 1352 Byte
Status
Exec Time 1192 ms
Memory 6372 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
× 3
× 31
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 82 ms 6336 KB
0_001.txt 83 ms 6360 KB
0_002.txt 82 ms 6360 KB
1_003.txt 83 ms 6360 KB
1_004.txt 81 ms 6368 KB
1_005.txt 83 ms 6328 KB
1_006.txt 81 ms 6240 KB
1_007.txt 81 ms 6368 KB
1_008.txt 83 ms 6364 KB
1_009.txt 82 ms 6372 KB
1_010.txt 82 ms 6364 KB
1_011.txt 82 ms 6364 KB
1_012.txt 82 ms 6360 KB
1_013.txt 88 ms 6368 KB
1_014.txt 110 ms 6364 KB
1_015.txt 110 ms 6368 KB
1_016.txt 114 ms 6368 KB
1_017.txt 217 ms 6368 KB
1_018.txt 1192 ms 6364 KB
1_019.txt 87 ms 6328 KB
1_020.txt 88 ms 6368 KB
1_021.txt 88 ms 6372 KB
1_022.txt 87 ms 6328 KB
1_023.txt 87 ms 6360 KB
1_024.txt 87 ms 6368 KB
1_025.txt 112 ms 6364 KB
1_026.txt 984 ms 6320 KB
1_027.txt 111 ms 6360 KB
1_028.txt 872 ms 6364 KB
1_029.txt 113 ms 6364 KB
1_030.txt 1009 ms 6244 KB