hdu 4584 水题爽一发 *

时间:2021-07-02 09:02:16
 #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
const int INF=0x3f3f3f3f;
const double eps=1e-;
typedef long long ll;
#define cl(a) memset(a,0,sizeof(a))
#define ts printf("*****\n");
const int MAXN=;
char s[][];
int n,m,tt;
pair<int,int> p1[MAXN],p2[MAXN],ans1,ans2;
int dis(int i,int j)
{
return (abs(p1[i].first-p2[j].first)+abs(p1[i].second-p2[j].second));
}
int main()
{
int i,j,k;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
while(scanf("%d%d",&n,&m)!=EOF)
{
if(n==&&m==) break;
int tot1=,tot2=;
for(i=;i<n;i++)
{
scanf("%s",s[i]);
for(j=;j<m;j++)
{
if(s[i][j]=='H') p1[tot1++]=make_pair(i,j);
if(s[i][j]=='C') p2[tot2++]=make_pair(i,j);
}
}
int Min=;
for(i=;i<tot1;i++)
{
for(j=;j<tot2;j++)
{
if(dis(i,j)<Min)
{
Min=dis(i,j);
ans1=p1[i];
ans2=p2[j];
}
}
}
printf("%d %d %d %d\n",ans1.first,ans1.second,ans2.first,ans2.second);
}
}