Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include<iostream>
#include<string>
using namespace std;
int x[10000], H, W; string S;
int main() {
	cin >> W >> H;
	for (int i = 0; i < H; i++) {
		cin >> S; for (int j = 0; j < W; j++)if (S[j] == 'W')x[j + 1] += 1;
	}
	for (int i = 1; i <= W; i++)x[i] += x[i - 1];
	int SUM = x[H];
	int minid = 0, maxn = 10000000;
	for (int i = 0; i <= W; i++) {
		int cnt = (i*H - x[i]);
		int P = SUM - x[i]; cnt += P;
		if (maxn > cnt) { minid = i; maxn = cnt; }
	}
	cout << minid << ' ' << minid + 1 << endl;
	return 0;
}