View Code of Problem 3795

#include<stdio.h>
#define max(a,b) a>b?a:b
#define N 10005
int a[10005][3];
int main(){
    int n;
	while(~scanf("%d",&n)){
		char tmp[2];
	    for(int i = 0;i<n;i++){
		   for(int j = 0;j<3;j++){
		      scanf("%s",tmp);
		      if(tmp[0]=='R')
				  a[i][j] = 1;
			  else
				  a[i][j] = 0;
		   }
		}
		int ans = 0;
		for(int i = 0;i<1<<3;i++){
			int tans = 0,flag[3];
			for(int j = 0;j<3;j++){
			   flag[j] = (i&(1<<j))>0;
			}
			for(int j = 0;j<n;j++){
				int cnt[2] = {0};
				for(int k = 0;k<3;k++)
					cnt[a[j][k]^flag[k]]++;
				tans += max(cnt[0],cnt[1]);
			}
			ans = max(ans,tans);
		}
		printf("%d\n",ans);
	}
}

Double click to view unformatted code.


Back to problem 3795