Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

constexpr int IINF = INT_MAX;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> ecnt(n+1,0), wcnt(n+1,0);
    for(int i=0;i<m;i++){
        string d;
        cin >> d;
        for(int j=0;j<n;j++){
            if(d[j]=='W') wcnt[j+1]++;
            else ecnt[j+1]++;
        }
    }
    for(int i=0;i<n;i++){
        wcnt[i+1] += wcnt[i];
        ecnt[i+1] += ecnt[i];
    }
    int ans = -1, err = IINF;
    for(int i=0;i<=n;i++){
        if(ecnt[i]+(wcnt[n]-wcnt[i]) < err){
            ans = i;
            err = ecnt[i]+(wcnt[n]-wcnt[i]);
        }
    }
    cout << ans << " " << ans+1 << endl;
    return 0;
}