Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <cstdio>
#include <iostream>
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;

char board[110][10010];
int N, M;
int cnt_col[10010][2];
int imos[10010][2];

int main() {
  scanf("%d%d", &N, &M);
  for(int i=0; i<M; i++) {
    for(int j=0; j<N; j++) {
      cin >> board[i][j];
      if(board[i][j] == 'W') cnt_col[j][0]++;
      else cnt_col[j][1]++;
    }
  }

  rep(i,0,N) rep(j,0,2) imos[i+1][j] = imos[i][j] + cnt_col[i][j];

  int mi = 1 << 30, idx = 0;
  rep(i,0,N+1) {
    int lw = imos[i][0], le = imos[i][1];
    int rw = imos[N][0] - lw, re = imos[N][1] - le;

    // printf("idx = %d, lw = %d, le = %d, rw = %d, re = %d\n", i, lw, le, rw, re);
    int error = le + rw;
    if(mi > error) {
      mi = error;
      idx = i;
    }
  }
  printf("%d %d\n", idx, idx+1);   
  return 0;
}