hdu 4584 Building bridges
2013-09-26 11:37
417 查看
水题
#include <cstdio> #include <cstdlib> struct node { int x; int y; }; node C[1605]; node H[1605]; int l_c,l_h; int main() { //freopen("in.txt","r",stdin); int n,m; while(scanf("%d%d",&n,&m)!=EOF) { if(!n&&!m) break; l_c=l_h=0; int x1,y1,x2,y2; int min=81; char ch; for(int i=0; i<n; ++i) { getchar(); for(int j=0; j<m; ++j) { scanf("%c",&ch); if(ch=='C') { C[l_c].x=i; C[l_c].y=j; ++l_c; } else if(ch=='H') { H[l_h].x=i; H[l_h].y=j; ++l_h; } } } for(int i=0; i<l_h; ++i) for(int j=0; j<l_c; ++j) if(min>abs(H[i].x-C[j].x)+abs(H[i].y-C[j].y)) { x1=H[i].x; y1=H[i].y; x2=C[j].x; y2=C[j].y; min=abs(H[i].x-C[j].x)+abs(H[i].y-C[j].y); } printf("%d %d %d %d\n",x1,y1,x2,y2); } return 0; }
相关文章推荐
- leetcode_question_45 Jump Game II
- 解决 iOS7 通过tag 找不到 UITableViewCell 的子控件
- 前台EasyUI哪些事一
- Air Max Shoes is Best Alternative if You Want to Purchase Suitable Shoes For You
- VC编译出现“Internal error during IncrBuildImage”错误
- ZOJ Problem Set - 1292 Integer Inquiry
- BIOS MCSDK 2.0 User Guide - Acronyms and Definitions
- Java中对产生serialVersionUID的警告解释
- iOS: UUID and SSKeyChain
- rebuild gsettings schemas
- SVN问题:Server sent unexpected return value (403 Forbidden) in response to OPTIONS
- UITableView的组的自定义与cell的重用
- 一个简单的java版GUI窗口
- Virtualbox – Host guest communication.
- openvswitch rhel6 rpm build
- kvm windows guest NMI crash dump in libvirt
- Resolve VNC and guest cursor are not consistence
- Why the new value is not usable after set PATH in cmd?
- mongoVUE查询
- Unique Binary Search Trees II