Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	int n, m;
	cin >> n >> m;
	vector<int>w(n), e(n);
	for (int k = 0; k < m; ++k)
	{
		string s;
		cin >> s;
		for (int i = 0; i < n; ++i)
		{
			char c = s[i];
			if (c == 'W')
			{
				w[i]++;
			}
			else
			{
				e[i]++;
			}
		}
	}
	vector<int>west(1, 0), east(1, 0);
	for (int ww : w)west.push_back(west.back() + ww);
	for (int ee : e)east.push_back(east.back() + ee);
	int best = INT_MAX;
	int ans = -1;
	for (int i = 0; i <= n; ++i)
	{
		int gos = east[i] + west[n] - west[i];
		if (gos < best)
		{
			best = gos;
			ans = i;
		}
	}
	cout << ans << " " << ans + 1 << endl;
	return 0;
}