Problem: Example

Input

2 1
WE


Output

1 2

Solution (in CPP):

Solution:
/*  -*- coding: utf-8 -*-
 *
 * 2717.cc: Where is the Boundary
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10000;
const int MAX_M = 100;
const int INF = 1 << 30;

/* typedef */

/* global variables */

char cs[MAX_N + 1];
int es[MAX_N], esums[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++) {
    scanf("%s", cs);
    for (int j = 0; j < n; j++)
      if (cs[j] == 'E') es[j]++;
  }

  esums[0] = 0;
  for (int i = 0; i < n; i++) esums[i + 1] = esums[i] + es[i];
  //for (int i = 0; i < n; i++) printf("%d ", es[i]); putchar('\n');

  int minsum = INF, mini = -1;
  for (int i = 0; i <= n; i++) {
    int sum = esums[i] + (m * (n - i) - (esums[n] - esums[i]));
    if (minsum > sum) minsum = sum, mini = i;
  }

  printf("%d %d\n", mini, mini + 1);
  return 0;
}