Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> ws(n+2, 0), es(n+2, 0);
	for(int i=0; i<m; i++){
		for(int j=1; j<=n; j++){
			char cul;
			cin >> cul;
			if(cul=='W') ws[j]++;
			else es[j]++;
		}
	}
	
	for(int i=1; i<=n; i++){
		es[i]+=es[i-1];
	}
	for(int i=n; i>0; i--){
		ws[i]+=ws[i+1];
	}
	
	int ans = -1;
	int err = 1e9;
	for(int i=0; i<=n; i++){
		if(es[i]+ws[i+1] < err){
			ans = i;
			err = es[i]+ws[i+1];
		}
	}
	cout << ans << " " << ans+1 << endl;
	return 0;
}