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 ...
随机推荐
- JDK6中System.getProperties返回键值说明
JDK6中java.lang.System.getProperties()方法返回键值说明. 键 相关值的描述 java.version Java 运行时环境版本 java.vendor Java 运 ...
- windows 迁移数据库
1) Prerequisites ---------------- - The copy of the datafiles must be done with the database clos ...
- C. Timofey and a tree 观察题 + dfs模拟
http://codeforces.com/contest/764/problem/C 题意:在n个顶点中随便删除一个,然后分成若干个连通子图,要求这若干个连通子图的颜色都只有一种. 记得边是双向的, ...
- HTML标签,简单归纳
列表标签 有序列表: <ol><li></li></ol> 无序列表: <ul><li></li></ul&g ...
- Godaddy域名301跳转问题处理
前言:Godaddy的域名301跳转一共有六步,详情见以下步骤: 第一步: 第二步:找到你的域名,并点击DNS 第三步:点击添加 第四步:添加解析ip地址 第五步:域名转址,也就是301跳转 第六步: ...
- [安卓开发板]迅为IMX6 四核Android开发板
工业级核心板-Android开发板 10层高速PCB设计,充分保证电磁兼容 处理器:开发板默认是四核商业扩展级芯片,可根据用户需求更换单核.双核.工业级.汽车级处理器,批量更省成本. 扩展引脚:320 ...
- css 样式通用样式
属性: vertical-align (这个属性主要作用是用于将相邻的文本与元素对齐,用于对齐行内元素,也就是说,display 的属性为 inline. inline-block 行内块,顾名 ...
- Linux 的 Spinlock 在 MIPS 多核处理器中的设计与实现
引言 随着科技的发展,尤其是在嵌入式领域,高性能.低功耗的处理器成为众多厂商追逐的目标,但是由于技术和工艺的瓶颈,试图在单核处理器上达到这样的目标变得越发困难,于是人们提出了多核处理器的概念.多核处理 ...
- JavaScript 原生代码找对象的方法
1. id : document.getElementById('id') 2. 标签 : document.getElementsByTagName('标签') //获得的是一个标签数组 3. N ...
- C#解析单层html的中的文本,然后拼接起来
匹配单层html的小demo,应该能匹配大多数html字符串.多层(嵌套)html标签解析不出来.可能有小bug,我抛砖引玉下,哈哈. using System; using System.Colle ...