Moocryption
Moocryption
题目描述
USOPEN
OOMABO
MOOMXO
PQMROM
Being cows, their only word of interest is "MOO", which can appear in the word finder in many places, either horizontally, vertically, or diagonally. The example above contains 6 MOOs.
Farmer John is also a fan of word puzzles. Since the cows don't want him to solve their word finder before they have a chance to try it, they have encrypted its contents using a "substitution cipher" that replaces each letter of the alphabet with some different letter. For example, A might map to X, B might map to A, and so on. No letter maps to itself, and no two letters map to the same letter (since otherwise decryption would be ambiguous).
Unfortunately, the cows have lost track of the substitution cipher needed to decrypt their puzzle. Please help them determine the maximum possible number of MOOs that could exist in the puzzle for an appropriate choice of substitution cipher.
输入
输出
样例输入
4 6
TAMHGI
MMQVWM
QMMQSM
HBQUMQ
样例输出
6
提示
This is the same puzzle at the beginning of the problem statement after a cipher has been applied. Here "M" and "O" have been replaced with "Q" and "M" respectively.
分析:枚举每个点,对每个点,枚举他的8个方向,注意起点不能是M,终点不能是O了;
代码:
#include <bits/stdc++.h>
#define ll long long
const int maxn=1e5+;
using namespace std;
int n,m,k,t,ma,p[][];
char a[][];
int dis[][]={,,,-,,,-,,,-,,,-,,-,-};
void check(int x,int y)
{
for(int i=;i<;i++)
{
int s[],t[];
s[]=x+dis[i][];
s[]=x+dis[i][]*;
t[]=y+dis[i][];
t[]=y+dis[i][]*;
if(s[]>=&&s[]<n&&t[]>=&&t[]<m&&a[x][y]!=a[s[]][t[]]&&a[s[]][t[]]==a[s[]][t[]]&&a[x][y]!='M'&&a[s[]][t[]]!='O')
ma=max(ma,++p[a[x][y]][a[s[]][t[]]] );
}
}
int main()
{
int i,j;
scanf("%d%d",&n,&m);
for(i=;i<n;i++)scanf("%s",a[i]);
for(i=;i<n;i++)
for(j=;j<m;j++)
{
check(i,j);
}
printf("%d\n",ma);
//system("pause");
return ;
}
Moocryption的更多相关文章
随机推荐
- vim编程配置方法
vim简介Vim 有以下几个模式:1) 正常(normal)模式,缺省的编辑模式:下面如果不加特殊说明,提到的命令都直接在正常模式下输入:任何其它模式中都可以通过键盘上的 Esc 键回到正常模式.2) ...
- docker Swarm 集群发现
Node 发现 $swarm manage --discovery dockerhost01:,dockerhost02:,dockerhost03: -H= 文件发现 $swarm manage - ...
- Ansible1:简介与基本安装【转】
Ansible是一个综合的强大的管理工具,他可以对多台主机安装操作系统,并为这些主机安装不同的应用程序,也可以通知指挥这些主机完成不同的任务.查看多台主机的各种信息的状态等,ansible都可以通过模 ...
- js获取后台json数据显示在jsp页面元素
jsp id <font size=2 >Today:</font> <font id ="todaytotal" size=2 color=&quo ...
- android,view的执行过程onDraw、onSizeChanged,onFinishInflate
小试view的执行过程,此是入门,高手绕道. ----------------------------------------------------------------------------- ...
- Qt中利用QTime类来控制时间,这里简单介绍一下QTime的成员函数的用法:
Qt中利用QTime类来控制时间,这里简单介绍一下QTime的成员函数的用法: ------------------------------------------------------------ ...
- Linq List<String>
List<string> _year = new List<string>() { "一月", "二月", "三月" ...
- iperf linux版本移植到android (使用工具链方式不是使用Android.mk)
由于很多程序是用makefile编译linux应用程序的,如果移植到android就要重新写Android.mk,对于不熟悉这个的人来说,特别麻烦,所以这里介绍只修改makefile就能移植到andr ...
- accept: Invalid argument linux 网络编程
今天测试一个本地网络通讯,在ubuntu虚拟机下出现的问题,警报:accept: Invalid argument 初始化地方: socklen_t clilen;struct sockaddr_in ...
- ng-if 和 ng-show/ng-hide 之间的区别
ng-if会移除dom,生成dom,而ng-show只是改变其display属性.所以你自己看着用吧.