Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

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

using namespace std;
typedef long long ll;

int n, m;
int cw[10010], ce[10010];
string s[110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s[i];
  }
  for (int j = 0; j < n; j++) {
    int cntw = 0, cnte = 0;
    for (int i = 0; i < m; i++) {
      cntw += s[i][j] == 'W';
      cnte += s[i][j] == 'E';
    }
    cw[j + 1] = cntw;
    ce[j + 1] = cnte;
  }
  for (int j = n + 1; j > 0; j--) {
    cw[j - 1] += cw[j];
  }
  for (int j = 0; j < n + 1; j++) {
    ce[j + 1] += ce[j];
  }

  int d = 1 << 30, ans = -1;
  for (int i = 0; i <= n; i++) {
    int nd = cw[i + 1] + ce[i];
    if (nd < d) {
      ans = i;
      d = nd;
    }
  }
  cout << ans << " " << ans + 1 << endl;

  return 0;
}