Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;

int main()
{
  int N, M;
  string S[100];
  int sum[10002] = {};

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> S[i];
  }

  for(int i = 0; i < M; i++) {
    for(int j = 0; j < N; j++) {
      if(S[i][j] == 'W') ++sum[j + 1];
    }
  }

  for(int i = 1; i <= N; i++) {
    sum[i] += sum[i - 1];
  }

  int ret = 1 << 30;

  for(int i = 0; i <= N; i++) {
    ret = min(ret, M * i - 2 * sum[i]);
  }

  for(int i = 0; i <= N; i++) {
    if(ret == M * i - 2 * sum[i]) {
      cout << i << " " << i + 1 << endl;
      break;
    }
  }

}