• HDU 4584


     1 //也是简单题,因为n太小,故暴力之!
     2 
     3 
     4 #include<stdio.h>
     5 #include<math.h>
     6 #include<string.h>
     7 #define max 45
     8 
     9 char map[max][max];
    10 
    11 int dis(int x1,int y1,int x2,int y2){
    12     return fabs(x1-x2*1.0)+fabs(y1-y2*1.0);
    13 }
    14 
    15 int main(){
    16     int n,m;
    17     while(~scanf("%d%d",&n,&m)){
    18         if(n==0&&m==0){
    19             break;
    20         }
    21         getchar();
    22         for(int i=0;i<n;i++){
    23             scanf("%s",map[i]);
    24         //    puts(map[i]);
    25         }
    26         int ans=99999,x1,y1,x2,y2;
    27         for(int i=0;i<n;i++){
    28             for(int j=0;j<m;j++){
    29                 if(map[i][j]!='H'){
    30                     continue;
    31                 }
    32                 for(int k=0;k<n;k++){
    33                     for(int h=0;h<m;h++){
    34                         if(map[k][h]!='C'){
    35                             continue;
    36                         }
    37                         int res=dis(i,j,k,h);
    38                                       if(ans>res){
    39                             ans=res;
    40                             x1=i; y1=j;
    41                             x2=k; y2=h;
    42                         }
    43                                      }
    44                 }
    45             }
    46             }
    47         printf("%d %d %d %d
    ",x1,y1,x2,y2);
    48     }
    49 }
  • 相关阅读:
    linux下使用OpenCV的一些问题
    Google Colab调用cv2.imshow奔溃
    [LeetCode] Word Search
    信号
    信号
    [Leetcode] Subsets
    [LeetCode] Combinations
    [LeetCode] Minimum Window Substring
    [LeetCode] Set Matrix Zeroes
    sigaction 函数
  • 原文地址:https://www.cnblogs.com/Stomach-ache/p/3703210.html
Copyright © 2020-2023  润新知