Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<char>> d(m, vector<char>(n));
  for (int i = 0; i < m; i++){
    for (int j = 0; j < n; j++){
      cin >> d[i][j];
    }
  }
  vector<int> L(n + 1, 0);
  for (int i = 0; i < n; i++){
    L[i + 1] = L[i];
    for (int j = 0; j < m; j++){
      if (d[j][i] == 'E'){
        L[i + 1]++;
      }
    }
  }
  vector<int> R(n + 1, 0);
  for (int i = n - 1; i >= 0; i--){
    R[i] = R[i + 1];
    for (int j = 0; j < m; j++){
      if (d[j][i] == 'W'){
        R[i]++;
      }
    }
  }
  int ans = INF;
  int pos = -1;
  for (int i = 0; i <= n; i++){
    if (L[i] + R[i] < ans){
      ans = L[i] + R[i];
      pos = i;
    }
  }
  cout << pos << ' ' << pos + 1 << endl;
}