hihoCoder#1094 Lost in the City
限时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的更多相关文章
- hihoCoder #1094 : Lost in the City(枚举,微软苏州校招笔试 12月27日 )
#1094 : Lost in the City 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He ...
- 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 ...
- #1094 : Lost in the City
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He does not know where he is ...
- hihoCoder#1094
刚开始学习C语言,准备在做hiho的题目的过程中来学习,在此进行记录,如果代码中有错误或者不当的地方还请指正. 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Littl ...
- #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 ...
- hihoCoder太阁最新面经算法竞赛15
hihoCoder太阁最新面经算法竞赛15 Link: http://hihocoder.com/contest/hihointerview24 题目1 : Boarding Passes 时间限制: ...
- [HihoCoder] Highway 高速公路问题
Description In the city, there is a one-way straight highway starts from the northern end, traverses ...
- hihoCoder 1389 Sewage Treatment 【二分+网络流+优化】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)
#1389 : Sewage Treatment 时间限制:2000ms 单点时限:2000ms 内存限制:256MB 描述 After years of suffering, people coul ...
- hihocoder -1121-二分图的判定
hihocoder -1121-二分图的判定 1121 : 二分图一•二分图判定 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 大家好,我是小Hi和小Ho的小伙伴Net ...
随机推荐
- Codeforces Round #235 (Div. 2) D (dp)
以为是组合,后来看着像数位dp,又不知道怎么让它不重复用..然后就没思路 了. 其实状压就可以了 状压是可以确定一个数的使用顺序的 利用01也可以确定所有的数的使用以及不重复 dp[i+1<&l ...
- React.js 简介
React.js 是一个帮助你构建页面 UI 的库.如果你熟悉 MVC 概念的话,那么 React 的组件就相当于 MVC 里面的 View.如果你不熟悉也没关系,你可以简单地理解为,React.js ...
- Oracle的一些名词和概念
1.数据库 这里的数据库不是通常情况下我们所说的数据库,而是一个Oracle的专业名词.它是磁盘上存储数据的集合,在物理上表现为数据文件. 日志文件和控制文件等,在逻辑上以表空间形式存在.使用时,必须 ...
- 使用Dotfuscator保护.NET DLL加密DLL,防止DLL反编译
1.下载地址 https://pan.baidu.com/s/1ztWlBxw1Qf462AE7hQJQRg 2.操作步骤 2.1安装后打开DotfuscatorPro软件,如下图所示: 2.2 选择 ...
- Activiti工作流和shiro权限管理关系图
- [BZOJ2456]mode 其它
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2456 这道题有着神奇的内存限制1MB也就是说我们是没办法把读入的数字存下来的. 由于答案求 ...
- css中border制作各种形状
css利用border制作各种形状的原理如图: 使用border绘制三角形是什么原理?事实上,宽度相等的border是以45度对接的,如下图: 没有了上border如图所示: 再设置border的宽度 ...
- qt查找框设置
转载请注明出处:http://www.cnblogs.com/dachen408/p/7229129.html 主界面弹出查找框方法,查找框显示在主界面上层,并还可以点击主界面,非模态. class ...
- leetcode_655. Print Binary Tree
https://leetcode.com/problems/print-binary-tree/ 打印整棵二叉树 class Solution { public: int getTreeHeight( ...
- c++ 模板template
1.函数模板的声明 声明形式 template<typename 数据类型参数标识符> <返回类型><函数名>(参数表) { 函数体 } 注: templa ...