<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      MATHHEW

      導航

      hihoCoder#1094

       

      剛開始學習C語言,準備在做hiho的題目的過程中來學習,在此進行記錄,如果代碼中有錯誤或者不當的地方還請指正。

       

      時間限制:10000ms
      單點時限:1000ms
      內存限制:256MB

      描述

      Little Hi gets lost in the city. He does not know where he is. He does not know which direction is north.

      Fortunately, Little Hi has a map of the city. The map can be considered as a grid of N*M blocks. Each

      block is numbered by a pair of integers. The block at the north-west corner is (1, 1) and the one at the

      south-east corner is (N, M). Each block is represented by a character, describing the construction on that

      block: '.' for empty area, 'P' for parks, 'H' for houses, 'S' for streets, 'M' for malls, 'G' for government

      buildings, 'T' for trees and etc.

      Given the blocks of 3*3 area that surrounding Little Hi(Little Hi is at the middle block of the 3*3 area),

      please find out the position of him. Note that Little Hi is disoriented, the upper side of the surrounding

      area may be actually north side, south side, east side or west side.

      輸入

      Line 1: two integers, N and M(3 <= N, M <= 200).
      Line 2~N+1: each line contains M characters, describing the city's map. The characters can only be 'A'-'Z' or '.'.
      Line N+2~N+4: each line 3 characters, describing the area surrounding Little Hi.

      輸出

      Line 1~K: each line contains 2 integers X and Y, indicating that block (X, Y) may be Little Hi's position. If there

      are multiple possible blocks, output them from north to south, west to east.

      樣例輸入
      8 8
      ...HSH..
      ...HSM..
      ...HST..
      ...HSPP.
      PPGHSPPT
      PPSSSSSS
      ..MMSHHH
      ..MMSH..
      SSS
      SHG
      SH.
      樣例輸出
          5 4

      解決思路

      從(2,2)開始到(n-1,m-1)的方塊中的每一個元素進行分析,看其是否滿足。分析元素過程:首先順時針

      分析離得最近的四個如果滿足,再順時針分析四個角上的是否滿足(注意一旦四個最近的順序確定了

      那么四個角上的順序也就定下來了)。最后輸出所有滿足條件的結果。

       

      #include<stdio.h>
      
      int JudgeThePos(char **Map,int i,int j);
      
      char HPos[3][3];
      char HPosDir[4],HPosOblDir[4],HPosPos;
      int n,m;
      
      int main()
      {
          char **Map,EKey;
          int i,j;
          scanf("%d%d",&n,&m);
      //初始化地圖 
          Map=(char **)malloc(n*sizeof(char*));
          for(i=0;i<n;i++)
          Map[i]=(char *)malloc(m*sizeof(char*));
          scanf("%c",&EKey);
          for(i=0;i<n;i++)
          {
              for(j=0;j<m;j++)
                  scanf("%c",&Map[i][j]);
              scanf("%c",&EKey);
          }
      //讀取位置 
          for(i=0;i<3;i++)
          {
              for(j=0;j<3;j++)
                  scanf("%c",&HPos[i][j]);
              scanf("%c",&EKey);
          }
      //初始化位置
          HPosDir[0]=HPos[0][1]; HPosDir[1]=HPos[1][2];
          HPosDir[2]=HPos[2][1]; HPosDir[3]=HPos[1][0];
          HPosOblDir[0]=HPos[0][2]; HPosOblDir[1]=HPos[2][2];
          HPosOblDir[2]=HPos[2][0]; HPosOblDir[3]=HPos[0][0];
          HPosPos=HPos[1][1];
      //對(2,2)到(n-1,m-1)的方塊內的每一個位置進行判斷
          for(i=1;i<n-1;i++)
          {
              for(j=1;j<m-1;j++)
              {
                  if(JudgeThePos(Map,i,j)==1)
                  printf("%d %d\n",i+1,j+1);
              }
          }
          free(Map);
          return 0;
      }
      
      int JudgeThePos(char **Map,int i,int j)
      {
          int k,l,p,q;
          char PosDir[4],PosOblDir[4],PosPos;
          PosDir[0]=Map[i-1][j];
          PosDir[1]=Map[i][j+1];
          PosDir[2]=Map[i+1][j];
          PosDir[3]=Map[i][j-1];
          PosOblDir[0]=Map[i-1][j+1];
          PosOblDir[1]=Map[i+1][j+1];
          PosOblDir[2]=Map[i+1][j-1];
          PosOblDir[3]=Map[i-1][j-1];
          PosPos=Map[i][j];
      //判斷位置
          if(PosPos!=HPosPos)
          return 0;
      //判斷正方向
          for(k=0;k<4;k++)
          {
              p=0;q=0;
              for(l=0;l<4;l++)
              {
                  if((k+p)==4)
                  p=-k;
                  if(HPosDir[l]==PosDir[k+p])
                  {
                      p++;
                      q++;
                  }
                  else
                  break;
              }
              if(q==4)
              break;
          }
      //判斷斜方向 
          if(q==4)
          {
              p=0;q=0;
              for(l=0;l<4;l++)
              {
                  if((k+p)==4)
                  p=-k;
                  if(HPosOblDir[l]==PosOblDir[k+p])
                  {
                      p++;
                      q++;
                  }
                  else
                  break;
              }
              if(q==4)
              return 1;
              else
              return 0;
          }
          else
          return 0;
      }

       

      posted on 2015-10-02 21:34  MATHHEW  閱讀(200)  評論(0)    收藏  舉報

      主站蜘蛛池模板: 保山市| 日日猛噜噜狠狠扒开双腿小说| 亚洲欧美中文日韩V在线观看| 免费无码va一区二区三区| 吃奶还摸下面动态图gif| 精品国产精品国产偷麻豆| 成人特黄特色毛片免费看| 九九热久久只有精品2| 亚洲性猛交xxxx| 国产午夜精品在人线播放| 国产精品av中文字幕| 青青草无码免费一二三区 | 日本一道一区二区视频| 国产成人AV国语在线观看| 日韩精品一区二区三区久| 揭阳市| 精品国产欧美一区二区三区在线| 97一期涩涩97片久久久久久久| 亚洲黄色成人网在线观看| 欧美国产日韩久久mv| 无码av中文字幕久久专区| 免费看亚洲一区二区三区| 无码人妻精品一区二区三| 狼人大伊人久久一区二区| 国产三级精品三级在线看| 免费VA国产高清大片在线| 97精品人妻系列无码人妻| 日韩中文字幕综合第二页| 西西人体www大胆高清| 狠狠躁日日躁夜夜躁欧美老妇 | 日本高清视频色欧WWW| 精品综合久久久久久98| 无码av片在线观看免费| 成人免费A级毛片无码片2022 | 国产jjizz女人多水喷水| 国产精品毛片一区视频播| 午夜福利精品一区二区三区| 欧美日本在线一区二区三区| 日本一区二区三区在线播放| 国产成人精品性色av麻豆| 亚洲国产成熟视频在线多多 |