Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> v(m);
    REP (i, 0, m) cin >> v[i];
    vector<lli> w(n + 1, 0), e(n + 1, 0);
    REP (i, 0, m) REP (j, 0, n) {
        if (v[i][j] == 'W') w[j]++;
        else e[j + 1]++;
    }
    REP (i, 0, n) {
        e[i + 1] += e[i];
        w[n - i - 1] += w[n - i];
    }
    int idx = 0;
    lli error = 1 << 30;
    REP (i, 0, n + 1) {
        lli er = w[i] + e[i];
        if (er < error) {
            error = er;
            idx = i;
        }
    }
    cout << idx << ' ' << idx + 1 << endl;
    return 0;
}