天天看点

Codeforces 1028A Find Square

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int n, m;
char temp[120][120];
int lx, ly, rx, ry;

int main() {
	scanf("%d %d", &n, &m);
	getchar();
	for (int i = 0;i < n;++i) {
		scanf("%s", &temp[i]);
		getchar();
	}
	for (int i = 0;i < n;++i) {
		for (int j = 0;j < m;++j) {
			if (temp[i][j] == 'B') {
				lx = i;
				ly = j;
				goto x;
			}
		}
	}

x:  for (int i = 0;i < n;++i) {
	for (int j = 0;j < m;++j) {
		if (temp[i][j] == 'B'&&temp[i+1][j]!='B'&&temp[i][j+1]!='B') {
			rx = i;
			ry = j;
			goto y;
		}
	}
    }
y:  printf("%d %d\n", (lx + rx + 2) / 2, (ly + ry + 2) / 2);
	//system("pause");
	return 0;
}
           
ACM