时间限制: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

代码实现:

 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 ])
 {
      + i; a++)
          + j; b++)
         {
             if (s1[a][b] != surround[a - i][b - j])
                 ;
         }

     ;
 }
 int main()
 {
     , m = ;
     scanf("%d %d", &n,&m);
     getchar();
     char** map = (char**)malloc(sizeof(char)*n);
     ; i<n; i++)
     {
         map[i] = (char*)malloc(sizeof(char)*m);
         fgets(map[i], m+, stdin);
         getchar();
     }
     ][] = {  };
     ; i<; i++)
     {
         fgets(surround[i], , stdin);
         getchar();
     }
     ][] = {  };
     ][] = {  };
     ][] = {  };
     ][];
     ; i<; i++)
     {
         ; j<; j++)
         {
             surround1[ - j][i] = surround[i][j];
         }
     }
     ; i<; i++)
     {
         ; j<; j++)
         {
             surround2[ - j][i] = surround1[i][j];
         }
     }
     ; i<; i++)
     {
         ; j<; j++)
         {
             surround3[ - j][i] = surround2[i][j];
         }
     }
     ; i<n - ; i++)
     {
         ; j<m - ; j++)
         {

             if (map[i][j] == position)
             {
                 , j - , surround))
                 {
                     printf(, j + );
                     continue;
                 }
                 , j - , surround1))
                 {
                     printf(, j + );
                     continue;
                 }
                 , j - , surround2))
                 {
                     printf(, j + );
                     continue;
                 }
                 , j - , surround3))
                 {
                     printf(, j + );
                     continue;
                 }
             }
         }
     }
     ;
 }

问题:

使用Visual Studio编译运行样例结果正确,但是提交代码通过G++运行会出现Wrong Answer,若知道原因的话还望请留言告知!

#1094 : Lost in the City by C solution的更多相关文章

  1. hihoCoder #1094 : Lost in the City(枚举,微软苏州校招笔试 12月27日 )

    #1094 : Lost in the City 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He ...

  2. hihocoder #1094 : Lost in the City微软苏州校招笔试 12月27日 (建图不大【暴力枚举】 子图的4种形态 1Y )

    #1094 : Lost in the City 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He ...

  3. #1094 : Lost in the City

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He does not know where he is ...

  4. hihoCoder#1094 Lost in the City

    原题地址 限时10s,所以不用考虑什么算法了,暴力吧 分别按照3x3视野的四个方向去地图上匹配,把符合的地点标记出来,最后统一按照从上到下,从左到右的顺序输出. 代码: #include <io ...

  5. 【BZOJ2001】 [Hnoi2010]City 城市建设

    BZOJ2001 [Hnoi2010]City 城市建设 Solution 我们考虑一下这个东西怎么求解? 思考无果...... 咦? 好像可以离线cdq,每一次判断一下如果这条边如果不选就直接删除, ...

  6. WATERHAMMER: A COMPLEX PHENOMENON WITH A SIMPLE SOLUTION

    开启阅读模式 WATERHAMMER A COMPLEX PHENOMENON WITH A SIMPLE SOLUTION Waterhammer is an impact load that is ...

  7. bzoj:1687;poj 2434:[Usaco2005 Open]Navigating the City 城市交通

    Description A dip in the milk market has forced the cows to move to the city. The only employment av ...

  8. [Swift]LeetCode807. 保持城市天际线 | Max Increase to Keep City Skyline

    In a 2 dimensional array grid, each value grid[i][j]represents the height of a building located ther ...

  9. [Swift]LeetCode1029. 两地调度 | Two City Scheduling

    There are 2N people a company is planning to interview. The cost of flying the i-th person to city A ...

随机推荐

  1. xcode

    1: info.plist IOS之Info.plist文件简介 http://www.apkbus.com/android-130240-1-1.html 在Xcode项目中读取plist文件 ht ...

  2. 研究kisso跨域登录的心得

    kisso OA所有请求都跳转到这个接口,登录只有这一个入口 http://my.web.com:8090/oa/login.ht @RequestMapping("/login.ht&qu ...

  3. 【C#进阶系列】04 类型基础

    关于System.Object 所有类型都从System.Object派生而来. System.Object的公共方法中ToString()一般是返回对象的类型的全名,只有Int32这些类型将其重写后 ...

  4. luoguP2267 琪琪的项链

    题目:http://www.luogu.org/problem/show?pid=2267 题解:这题略吊. 看了之后发现不能用组合数学直接得出公式,然后如果直接暴力也不知道如何去排除两个颜色序列相同 ...

  5. (转)C语言malloc()与free()的使用

    如何使用 malloc 函数 本文为转载内容,原文地址请点击 不要莫名其妙,其实上面这段小小的对话,就是malloc的使用过程.malloc是一个函数,专门用来从堆上分配内存.使用malloc函数需要 ...

  6. Spring Boot快速入门(最新)

    本章通过完成Spring Boot基础项目的构建并实现一个简单的Http请求处理,让大家对Spring Boot有一个初步的了解,并体验其结构简单.开发快速的特性.预计阅读及演练过程将花费约5分钟. ...

  7. python爬虫——对爬到的数据进行清洗的一些姿势(5)

    做爬虫,当然就要用数据.想拿数据进行分析,首先清洗数据.这个清洗数据包括清除无用数据列和维度,删除相同数据,对数据进行勘误之类的. 从各大不同新闻网站可以爬到重复新闻...这个可以有.之前为了对爬到的 ...

  8. C# p2p UDP穿越NAT,UDP打洞源码

    思路如下(参照源代码): 1. frmServer启动两个网络侦听,主连接侦听,协助打洞的侦听. 2. frmClientA和frmClientB分别与frmServer的主连接保持联系. 3. 当f ...

  9. MapReduce程序(一)——wordCount

    写在前面:WordCount的功能是统计输入文件中每个单词出现的次数.基本解决思路就是将文本内容切分成单词,将其中相同的单词聚集在一起,统计其数量作为该单词的出现次数输出. 1.MapReduce之w ...

  10. Delphi XE7调用C++动态库出现乱码问题回顾

    事情源于有个客户需使用我们C++的中间件动态库来跟设备连接通讯,但是传入以及传出的字符串指针格式都不正确(出现乱码或是被截断),估计是字符编码的问题导致.以下是解决问题的过程: 我们C++中间件动态库 ...