Zhuge Liang's Password

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 59    Accepted Submission(s): 47

Problem Description
  In the ancient three kingdom period, Zhuge Liang was the most famous and smart military leader. His enemy was Sima Yi, the military leader of Kingdom Wei. Sima Yi always looked stupid when fighting against Zhuge Liang. But it was 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.
 
Input
  There are several test cases.
  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
 
Output
  For each test case, print the password.
 
Sample Input
2
1 2
3 4
5 6
7 8
2
10 20
30 13
90 10
13 21
0
 
Sample Output
0
2
 
Source
 

水题。。。

写个函数进行旋转就可以了。

 /* ***********************************************
Author :kuangbin
Created Time :2013-11-9 12:44:06
File Name :E:\2013ACM\专题强化训练\区域赛\2013杭州\1003.cpp
************************************************ */ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std; const int MAXN = ;
int a[MAXN][MAXN];
int b[MAXN][MAXN];
int n;
void change()
{
int c[MAXN][MAXN];
for(int i = ;i < n;i++)
for(int j = ;j < n;j++)
{
c[i][j] = a[n--j][i];
}
for(int i = ;i < n;i++)
for(int j = ;j < n;j++)
a[i][j] = c[i][j];
} int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
while(scanf("%d",&n) == && n)
{
for(int i = ;i < n;i++)
for(int j = ;j < n;j++)
scanf("%d",&a[i][j]);
for(int i = ;i < n;i++)
for(int j = ;j < n;j++)
scanf("%d",&b[i][j]);
int ans = ;
for(int k = ;k < ;k++)
{
int cnt = ;
for(int i = ;i < n;i++)
for(int j = ;j < n;j++)
if(a[i][j] == b[i][j])
cnt++;
ans = max(ans,cnt);
change();
}
printf("%d\n",ans);
}
return ;
}

HDU 4772 Zhuge Liang's Password (2013杭州1003题,水题)的更多相关文章

  1. HDU 4772 Zhuge Liang&#39;s Password (简单模拟题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4772 题面: Zhuge Liang's Password Time Limit: 2000/1000 ...

  2. HDU 4738 Caocao's Bridges (2013杭州网络赛1001题,连通图,求桥)

    Caocao's Bridges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  3. HDU 4788 Hard Disk Drive (2013成都H,水题)

    Hard Disk Drive Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  4. HDU 4788 Hard Disk Drive (2013成都H,水题) 进位换算

    #include <stdio.h> #include <algorithm> #include <string.h> #include<cmath> ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. HDU 4770 Lights Against Dudely (2013杭州赛区1001题,暴力枚举)

    Lights Against Dudely Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

随机推荐

  1. 【NOI】2017 蚯蚓排队(BZOJ 4943,LOJ 2303) 模拟+hash

    [题目]#2303. 「NOI2017」蚯蚓排队 [题意]给定n条长度不超过6的蚯蚓,初始各自在一个队伍.m次操作:1.将i号蚯蚓和j号蚯蚓的队伍合并(保证i为队尾,j为队首).2.将i号蚯蚓和它后面 ...

  2. js基础知识:闭包,事件处理,原型

    闭包:其实就是js代码在执行的时候会创建变量对象的一个作用域链,标识符解析的时候会沿着作用域链一级一级的网上搜索,最后到达全局变量停止.所以某个函数可以访问外层的局部变量和全局变量,但是访问不了里层的 ...

  3. 【译】SQLskills SQL101:Trace Flags、ERRORLOG、Update Statistics

    最近阅读SQLskills SQL101,将Erin Stellato部分稍作整理.仅提取自己感兴趣的知识点,详细内容请阅读原文. 一.Trace Flags推荐开启三个跟踪标记1118.3023.3 ...

  4. 使用/dev/uinput的简要介绍(含demo程序)【转】

    转自:https://blog.csdn.net/zhongkunjia/article/details/75142699 uinput机制有2个很大的优点: 1) 不用自己写驱动(比如弄个红外遥控器 ...

  5. mycat学习笔记

    MyCAT简易入门_数据库技术_Linux公社-Linux系统门户网站http://www.linuxidc.com/Linux/2016-01/127382.htm mycat读写分离配置 - PE ...

  6. 读写分离MYSQL类

    2014年4月27日 12:34:08 概述: 1. 根据sql语句判断是连接读库还是写库 2. 链式调用$this->where()->get() 3. 不同的主机对应不同的实例, 不再 ...

  7. linux:根据名称杀死进程

    参考网址:https://www.cnblogs.com/foohack/p/5359985.html pkill -f "process_name_pattern"

  8. Android 7.0 新增功能和api

    Android 7.0 Nougat 为用户和开发者引入多种新功能.本文重点介绍面向开发者的新功能. 请务必查阅 Android 7.0 行为变更以了解平台变更可能影响您的应用的领域. 要详细了解 A ...

  9. Java中抽象类概述

    抽象类 1.抽象类的定义 抽象类是为子类提供一个规范,这就必须联系到继承: 抽象类的制定就是让子类继承的:  public abstract 类名{ //类体 //抽象方法 修饰符 abstract ...

  10. OPENCV SVM介绍和自带例子

    依据机器学习算法如何学习数据可分为3类:有监督学习:从有标签的数据学习,得到模型参数,对测试数据正确分类:无监督学习:没有标签,计算机自己寻找输入数据可能的模型:强化学习(reinforcement ...