View Code of Problem 3795

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

#define max(a,b) (a)>(b)?(a):(b)
#define MAXN 10010
typedef long long ll;
const int mod=1000000009;

int n;
int x[MAXN][3];

int main()
{
    while(~scanf("%d\n",&n))
    {
      //  getchar();
        char sa,sb,sc;
        for(int i=0;i<n;i++)
        {
            scanf("%c %c %c\n",&sa,&sb,&sc);
          //  getchar();
            if(sa=='R') x[i][0]=1;
            else x[i][0]=0;
            if(sb=='R') x[i][1]=1;
            else x[i][1]=0;
            if(sc=='R') x[i][2]=1;
            else x[i][2]=0;
        }
        int ans=0;
        for(int i=0;i<(1<<3);i++)  //ц╤╬ыв╢л╛
        {
            int tmp=0;
            int 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[x[j][k]^flag[k]]++;
                tmp+=max(cnt[0],cnt[1]);
            }
            ans=max(ans,tmp);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 3795