Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

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

int w, h;
string s[100];
int eNum[100][10001];
int wNum[100][10001];

int main() {
	int i, j;
	cin >> w >> h;
	for (i = 0; i < h; i++) cin >> s[i];
	for (i = 0; i < h; i++) {
		for (j = 1; j <= w; j++) {
			eNum[i][j] = eNum[i][j - 1] + (s[i][j - 1] == 'E');
			wNum[i][j] = wNum[i][j - 1] + (s[i][j - 1] == 'W');
		}
	}
	
	int minTotal = 1145141919;
	int ans;
	for (j = 0; j <= w; j++) {
		int total = 0;
		for (i = 0; i < h; i++) total += eNum[i][j];
		for (i = 0; i < h; i++) total += wNum[i][w] - wNum[i][j];
		if (minTotal > total) {
			minTotal = total;
			ans = j;
		}
	}
	
	cout << ans << " " << ans + 1 << endl;
	return 0;
}