原题地址

限时10s,所以不用考虑什么算法了,暴力吧

分别按照3x3视野的四个方向去地图上匹配,把符合的地点标记出来,最后统一按照从上到下,从左到右的顺序输出。

代码:

 #include <iostream>

 using namespace std;

 #define MAP_SIZE 250

 bool match(char map[MAP_SIZE][MAP_SIZE], char sight[][], int r, int c) {
for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
if (map[r + i][c + j] != sight[i][j])
return false;
return true;
} void find(char map[MAP_SIZE][MAP_SIZE], char sight[][], char res[MAP_SIZE][MAP_SIZE], int N, int M) {
for (int i = ; i < N - ; i++) {
for (int j = ; j < M - ; j++) {
if (match(map, sight, i, j))
res[i + ][j + ] = ;
}
}
} void rotate(char sight[][]) {
for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
swap(sight[i][j], sight[ - j][ - i]);
for (int i = ; i < ; i++)
swap(sight[][i], sight[][i]);
} int main() {
int N, M;
char map[MAP_SIZE][MAP_SIZE];
char res[MAP_SIZE][MAP_SIZE];
char sight[][]; cin >> N >> M;
for (int i = ; i < N; i++)
for (int j = ; j < M; j++)
cin >> map[i][j]; for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
cin >> sight[i][j]; memset(res, , MAP_SIZE * MAP_SIZE * sizeof(char)); for (int i = ; i < ; i++) {
find(map, sight, res, N, M);
rotate(sight);
} for (int i = ; i < N - ; i++)
for (int j = ; j < M - ; j++)
if (res[i][j])
cout << i + << " " << j + << endl; return ;
}

hihoCoder#1094 Lost in the City的更多相关文章

  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

    刚开始学习C语言,准备在做hiho的题目的过程中来学习,在此进行记录,如果代码中有错误或者不当的地方还请指正. 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Littl ...

  5. #1094 : Lost in the City by C solution

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

  6. hihoCoder太阁最新面经算法竞赛15

    hihoCoder太阁最新面经算法竞赛15 Link: http://hihocoder.com/contest/hihointerview24 题目1 : Boarding Passes 时间限制: ...

  7. [HihoCoder] Highway 高速公路问题

    Description In the city, there is a one-way straight highway starts from the northern end, traverses ...

  8. hihoCoder 1389 Sewage Treatment 【二分+网络流+优化】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)

    #1389 : Sewage Treatment 时间限制:2000ms 单点时限:2000ms 内存限制:256MB 描述 After years of suffering, people coul ...

  9. hihocoder -1121-二分图的判定

    hihocoder -1121-二分图的判定 1121 : 二分图一•二分图判定 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 大家好,我是小Hi和小Ho的小伙伴Net ...

随机推荐

  1. 四大开源协议比较:BSD、Apache、GPL、LGPL【转载】

    四大开源协议原文链接 本文参考文献:http://www.fsf.org/licensing/licenses/ 现今存在的开源协议很多,而经过Open Source Initiative组织通过批准 ...

  2. iOS开发之邮件发送代码

    邮件发送功能是由MessageUI Framework提供的,这个框架是iPhone sdk中最简单的框.由一个类.一个视图控制器,一个protocol组成. 一.创建视图控制器: MFMailCom ...

  3. [转]Business Model Canvas(商业模式画布):创业公司做头脑风暴和可行性测试的一大利器

    本文转自:http://www.36kr.com/p/214438.html 本文来自First Round Review,他们准备的文章既讲故事,还同时向创业者提供可操作的建议,以助力打造优秀的公司 ...

  4. [转]asp.net MVC helper 和自定义函数@functions小结

    本文转自:http://www.cnblogs.com/jiagoushi/p/3904995.html asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的 ...

  5. Java实现求二叉树的路径和

    题: 解: 这道题考的是如何找出一个二叉树里所有的序列. 我的思路是先从根节点开始遍历,找出所有的子节点,因为每个子节点只有一个父节点,再根据每个子节点向上遍历找出所有的序列,再判断序列的总和. 这样 ...

  6. install nginx error

    the error info : the HTTP gzip module requires the zlib library.You can either disable the module by ...

  7. 计算器Pro应用项目源码

    本计算器实现了一些简单的功能,可能本身还存在一些缺陷,希望大家提建议,能够改进一下. 源码项目我已经上传到源码天堂那里了:http://code.662p.com/list/11_1.html < ...

  8. 开源一个一个NodeJS 代理服务器扫描工具,可以用来***

    鉴于我朝很多网站访问不了,google等就是大悲剧,之前一直在用VPN,但是公司内网VPN被封,诸多工具也惨遭毒手..我辈怎能容忍. 目前只有代理没有被封,于是搞了个代理扫描工具并开源: https: ...

  9. [转]c++应用程序文件的编译过程

    原文地址 这里讲下C++文件的编译过程及其中模板的编译过程: 一:一般的C++应用程序的编译过程.    一般说来,C++应用程序的编译过程分为三个阶段.模板也是一样的. 在cpp文件中展开inclu ...

  10. android studio 调试安装

    最新的手机无法debug安装调试. vivo x21  oppo r11等 解决办法: 1,关闭instant run Android Studio->Preferences->Build ...