Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

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

using namespace std;


int main(void) {
    int h,w;
    cin >> w >> h;
    vector<vector<char> > g(h, vector<char>(w));
    int E = 0, W = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> g[i][j];
            if (g[i][j]=='E') E++;
            else W++;
        }
    }

    int e = W;
    int ec = 0, wc = 0, ans = -1;
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            if (g[j][i] == 'W') wc++;
            else ec++;
        }
        int error = W-wc + ec;
        if (error < e) e = error, ans = i;
    }
    cout << ans+1 << " " << ans+2 << endl;
}