Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  string d[100];
  for(int i = 0; i < m; i++) cin >> d[i];
  int W[10010] = {0}, E[10010] = {0};
  for(int i = 0; i < n; i++) {
    if(i) W[i+1] = W[i], E[i+1] = E[i];
    for(int j = 0; j < m; j++) {
      if(d[j][i] == 'W') W[i+1]++;
      else if(d[j][i] == 'E') E[i+1]++;
    }
  }
  int ans = 1<<25, idx = -1;
  for(int i = 0; i <= n; i++) {
    if(E[i]+W[n-1]-W[i] < ans) ans = E[i]+W[n-1]-W[i], idx = i;
  }
  cout << idx << " "<< idx+1 << endl;
  return 0;
}