HDU 4772 Zhuge Liang's Password(模拟水)

HDU 4772 Zhuge Liang‘s Password

题目链接

题意:给定两张牌,可以旋转后重叠,重合后相同数字最多的是密码,求密码

思路:直接模拟记录最大值即可

代码:

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

const int N = 35;
int n;
int a[N][N], b[N][N];

int solve() {
    int ans[4];
    memset(ans, 0, sizeof(ans));
    for (int i = 0; i < n; i++) {
	for (int j = 0; j < n; j++) {
	    if (b[i][j] == a[i][j]) ans[0]++;
	    if (b[j][n - i - 1] == a[i][j]) ans[1]++;
	    if (b[n - i - 1][n - j - 1] == a[i][j]) ans[2]++;
	    if (b[n - j - 1][i] == a[i][j]) ans[3]++;
	}
    }
    int Max = 0;
    for (int i = 0; i < 4; i++)
	Max = max(Max, ans[i]);
    return Max;
}

int main() {
    while (~scanf("%d", &n) && n) {
	for (int i = 0; i < n; i++)
	    for (int j = 0; j < n; j++)
		scanf("%d", &a[i][j]);
	for (int i = 0; i < n; i++)
	    for (int j = 0; j < n; j++)
		scanf("%d", &b[i][j]);
	printf("%d\n", solve());
    }
    return 0;
}

HDU 4772 Zhuge Liang's Password(模拟水)

时间: 2024-10-12 17:28:41

HDU 4772 Zhuge Liang's Password(模拟水)的相关文章

HDU 4772 Zhuge Liang&#39;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 Problem Description In the anc

HDU 4772 Zhuge Liang&#39;s Password

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

HDU 4772 Zhuge Liang&#39;s Password (矩阵旋转)

Zhuge Liang's Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 931    Accepted Submission(s): 641 Problem Description In the ancient three kingdom period, Zhuge Liang was the most famous

HDU 4772 Zhuge Liang&#39;s Password 选择矩阵

本题需要使用选择矩阵的程序求解,这个和Leetcode上的一个程序是一样道理的.如果使用额外空间,那么是很容易做到的,这里不使用额外空间,直接使用到位操作,空间效率是O(1),这是个非常漂亮的到位旋转程序. 题意还是很重要,这次看错了一句话,就WA了一次: The maximum amount of cells which contains two equal numbers after overlapping, is the password. 这里是需要每次旋转之后求相同数字的最大值,而不是

hdu 4739 Zhuge Liang&#39;s Mines 随机化

Zhuge Liang's Mines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4739 Description In the ancient three kingdom period, Zhuge Liang was the most famous and smartest military leader. His enemy was Shima Yi, who

HDU 4048 Zhuge Liang&#39;s Stone Sentinel Maze

Zhuge Liang's Stone Sentinel Maze Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 385    Accepted Submission(s): 106 Problem Description Zhuge Liang was a chancellor of the state of Shu Han dur

【HDU 1889】Reaux! Sham! Beaux!(模拟+水题)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1889 题意:给出一个表,每个国家的石头剪子布的叫法,给两个人用自己国家的语言进行石头剪子布,进行统计,最后输出胜负信息. 分析:就是模拟,先用map去映射每一个字符串,3种分别为1,2,3,然后进行统计判定即可,注意坑点就是输出时候有单复数区别,还有输出格式比较容易错. 代码: /* *********************************************** Author :Tor

HDU 4974 A simple water problem 模拟(水

水题. #include <cstdio> #include <iostream> #include <queue> #include <algorithm> using namespace std; typedef long long ll; priority_queue<int> q; int main() { int T, cas = 0; scanf("%d", &T); while(T-- > 0) {

HDOJ 2317. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of