HDU 4772 Zhuge Liang's Password (简单模拟题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4772
题面:
Zhuge Liang's Password
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1404 Accepted Submission(s): 926
Sima Yi who laughed to the end.
Zhuge Liang had led his army across the mountain Qi to attack Kingdom Wei for six times, which all failed. Because of the long journey, the food supply was a big problem. Zhuge Liang invented a kind of bull-like or horse-like robot called "Wooden Bull & Floating
Horse"(in abbreviation, WBFH) to carry food for the army. Every WBFH had a password lock. A WBFH would move if and only if the soldier entered the password. Zhuge Liang was always worrying about everything and always did trivial things by himself. Since Ma
Su lost Jieting and was killed by him, he didn't trust anyone's IQ any more. He thought the soldiers might forget the password of WBFHs. So he made two password cards for each WBFH. If the soldier operating a WBFH forgot the password or got killed, the password
still could be regained by those two password cards.
Once, Sima Yi defeated Zhuge Liang again, and got many WBFHs in the battle field. But he didn't know the passwords. Ma Su's son betrayed Zhuge Liang and came to Sima Yi. He told Sima Yi the way to figure out the password by two cards.He said to Sima Yi:
"A password card is a square grid consisting of N×N cells.In each cell,there is a number. Two password cards are of the same size. If you overlap them, you get two numbers in each cell. Those two numbers in a cell may be the same or not the same. You can
turn a card by 0 degree, 90 degrees, 180 degrees, or 270 degrees, and then overlap it on another. But flipping is not allowed. The maximum amount of cells which contains two equal numbers after overlapping, is the password. Please note that the two cards must
be totally overlapped. You can't only overlap a part of them."
Now you should find a way to figure out the password for each WBFH as quickly as possible.
In each test case:
The first line contains a integer N, meaning that the password card is a N×N grid(0<N<=30).
Then a N×N matrix follows ,describing a password card. Each element is an integer in a cell.
Then another N×N matrix follows, describing another password card.
Those integers are all no less than 0 and less than 300.
The input ends with N = 0
2
1 2
3 4
5 6
7 8
2
10 20
30 13
90 10
13 21
0
0
2
解题:
简单模拟下旋转就好。
代码:
#include <iostream>
using namespace std;
int m1[31][31],m2[31][31],m3[31][31],m4[31][31],m5[31][31];
int main()
{
int ans,cnt1,cnt2,cnt3,cnt4;
int n;
while(cin>>n&&n)
{
cnt1=cnt2=cnt3=cnt4=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
cin>>m1[i][j];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
cin>>m2[i][j];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
m3[j][i]=m2[i][n-j+1];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
m4[j][i]=m3[i][n-j+1];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
m5[j][i]=m4[i][n-j+1];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(m2[i][j]==m1[i][j])cnt1++;
if(m3[i][j]==m1[i][j])cnt2++;
if(m4[i][j]==m1[i][j])cnt3++;
if(m5[i][j]==m1[i][j])cnt4++;
}
}
ans=cnt1;
if(cnt2>ans)ans=cnt2;
if(cnt3>ans)ans=cnt3;
if(cnt4>ans)ans=cnt4;
cout<<ans<<endl;
}
return 0;
}
HDU 4772 Zhuge Liang's Password (简单模拟题)的更多相关文章
- HDU 4772 Zhuge Liang's Password (2013杭州1003题,水题)
Zhuge Liang's Password Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- 2019浙大校赛--A--Thanks, TuSimple!(简单模拟题)
这题前三段都是一堆吹爆赞助商的屁话,正式题目在图片下边,一个简单模拟题. 题目大意: 有n个男生,m个女生在进行舞会,其中一部分男生祥和比自己矮的女生跳舞,一部分男生想和比自己高的女生跳舞,一部分女生 ...
- hdu 4739 Zhuge Liang's Mines (简单dfs)
Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 4739 Zhuge Liang's Mines 随机化
Zhuge Liang's Mines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...
- HDOJ 4739 Zhuge Liang's Mines
Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- HDU 4048 Zhuge Liang's Stone Sentinel Maze
Zhuge Liang's Stone Sentinel Maze Time Limit: 10000/4000 MS (Java/Others) Memory Limit: 32768/327 ...
- HDU 4739 Zhuge Liang's Mines (2013杭州网络赛1002题)
Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- UVa 679 小球下落 简单模拟题,树
题目大意:给你一个完全二叉树,并且给他们编号,编号规则为左子树为2*k,右子树为2*k+1,每一个节点 上都有一个开关,初始时开关都处于关闭状态,小球碰到节点就会改变该点的开关的状态.然后给你I个小球 ...
- POJ 1008 简单模拟题
e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看di ...
随机推荐
- SSO单点登录系列6:cas单点登录防止登出退出后刷新后退ticket失效报500错
这个问题之前就发现过,最近有几个哥们一直在问我这个怎么搞,我手上在做另一个项目,cas就暂时搁浅了几周.现在我们来一起改一下你的应用(client2/3)的web.xml来解决这个2b问题,首先看下错 ...
- quick-cocos2d-x教程9:实例之加上背景图片
在梳理完quick-cocos2d-x框架的各个文件夹后,我们開始我们的实例教程,在helloworld后面.加上一张图片,lua编辑器,我用的lua editor.还不错. 我们首先还是參照教程.创 ...
- Maven 小技巧之 自动更新你的jar包
在做selenium 自动化测试的时候,我们经常遇到这样的情况:浏览器悄悄升级了.紧接着所有测试用例都Fail. 检查过日志之后发现,原来是升级过的浏览器,我们用原来的selenium已经无法操作. ...
- js 获取浏览器显示内容的宽度和高度
js获取浏览器显示内容的宽度和高度 CreateTime--2017年7月10日17:24:12Author:Marydon 1.获取浏览器屏幕显示d的网页宽度 /** * 得到浏览器显示的屏幕高 ...
- iOS开发之状态栏隐藏(问题篇)
一.基本应用 相信基本的隐藏办法网上很多,这里只简单说明一下 1⃣️改变全局状态栏 1.在项目的Info.plist文件里设置UIViewControllerBasedStatusBarAppeara ...
- 深入探析 Rational AppScan Standard Edition 新特性之 Glass Box 扫描
众所周知,Web 应用安全测试通常有黑盒安全测试和白盒安全测试两种方法.这两种方法孰优孰劣一直众议纷纷.广为公认的是,这两种测试方法有着良好地互补性,两种测试方法的结合是未来安全测试技术的发展趋势.G ...
- 每日一招:如何才能在A股持续盈利?
证券市场介入门槛低,是众多普通投资者希望实现自己的“中国梦”的首选场所,无论牛市熊市,源源不断的参与者前赴后继.在沪深A股这样一个大众市场,每年都在上演着七亏两平一赚的悲喜剧,赚钱的永远是少数人,但众 ...
- Atitit swt 4.3 4.4 4.5 新特性java attilax总结
Atitit swt 4.3 4.4 4.5 新特性java attilax总结 1. 4.5 Release - June 3, 20151 1.1. Older Releases1 2. SWT ...
- qtav----ffmeg在ubuntu和win10上的编译和运行
最近在windows上和ubuntu上都安装了qtav并且通过了编译测试,实测播放中英文的视频文件功能正常,有图像有声音. 大致情况是,操作系统ubuntu: wkr@sea-X550JK:~$ ca ...
- Nginx 变量漫谈
转自:http://blog.sina.com.cn/openrestyNginx 的配置文件使用的就是一门微型的编程语言,许多真实世界里的 Nginx 配置文件其实就是一个一个的小程序.当然,是不是 ...