回校了........刚好七夕,切一道水题继续生活.........
#include <iostream> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <vector> #include <set> #include <queue> #include <stack> #include <climits>//形如INT_MAX一类的 #define MAX 100005 #define INF 0x7FFFFFFF #define REP(i,s,t) for(int i=(s);i<=(t);++i) #define ll long long #define mem(a,b) memset(a,b,sizeof(a)) #define mp(a,b) make_pair(a,b) #define L(x) x<<1 #define R(x) x<<1|1 # define eps 1e-5 //#pragma comment(linker, "/STACK:36777216") ///传说中的外挂 using namespace std; int n,m; char map[44][44]; int main(){ while(cin >> n >> m) { if(n == 0 && m == 0) break; for(int i=0; i<n; i++) cin >> map[i]; int x1,y1,x2,y2; int tmp = 111111111; for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { if(map[i][j] == 'H') { for(int k=0; k<n; k++) { for(int l=0; l<m; l++) { if(map[k][l] == 'C') { int t = abs(i - k) + abs(j - l); if(tmp > t) { tmp = t; x1 = i; y1 = j; x2 = k; y2 = l; } } } } } } } printf("%d %d %d %d\n",x1,y1,x2,y2); } return 0; }