Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <iostream>
#include <vector>
#include <string>
using namespace std;

constexpr int INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> W(n+2), E(n+2);
    for(int i=0; i<m; ++i) {
        for(int j=0; j<n; ++j) {
            char c;
            cin >> c;
            if(c == 'E') {
                E[j+1]++;
            } else {
                W[j+1]++;
            }
        }
    }
    for(int i=0; i<n+1; ++i) {
        E[i+1] += E[i];
        W[i+1] += W[i];
    }

    int sum = INF;
    int res = 0;
    for(int i=0; i<=n+1; ++i) {
        if(sum > E[i] + (W[n+1] - W[i])) {
            res = i;
            sum = E[i] + (W[n+1] - W[i]);
        }
    }
    cout << res << " " << res+1 << endl;
}