HDU 4708:Rotation Lock Puzzle
Rotation Lock Puzzle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1836 Accepted Submission(s): 580
is maximum, the door is open.”.
Here, main diagonal is the diagonal runs from the top left corner to the bottom right corner, and anti-diagonal runs from the top right to the bottom left corner. The size of square matrix is always odd.

This sample is a square matrix with 5*5. The numbers with vertical shadow can be rotated around center ‘3’, the numbers with horizontal shadow is another queue. Alice found that if she rotated vertical shadow number with one step, the sum of two diagonals is
maximum value of 72 (the center number is counted only once).
5
9 3 2 5 9
7 4 7 5 4
6 9 3 9 3
5 2 8 7 2
9 9 4 1 9
0
72 1
迷失在幽谷中的鸟儿,独自飞翔在这偌大的天地间,却不知自己该飞往何方……
题意:给出一个n*n矩阵,n>=3&&n<=9,如果按照最大可能性,只有第二层和第四层有可能是垂直线段覆盖区域!垂直区域可以向逆时针或者顺时针旋转,求旋转几次可以使构成的新矩阵主对角线和副对角线的和最大!
一道简单可暴力解决的题目!因为n<=9!
#include<stdio.h>
#include<iostream>
using namespace std;
int ab[10][10];
int tl,tr,bl,br;
int main()
{
int n;
while(~scanf("%d",&n)&&n)
{
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
scanf("%d",&ab[i][j]);
int add=0,kk=0;
for(int i=1; i<=(n-1)/2; i++)
{
int sum=-0xffffff,ji=0;
for(int j=0; j<n-(i*2-1); j++)
{
tl=ab[i+j][i];
tr=ab[i][n-i+1-j];
bl=ab[n-i+1][i+j];
br=ab[n-i+1-j][n-i+1];
int oth=tl+tr+bl+br;
if(oth>sum)sum=oth,ji=j;
else if(oth==sum&&j<ji)ji=j;
}
for(int j=0; j<n-(i*2-1); j++)
{
tl=ab[i][i+j];
tr=ab[i+j][n-i+1];
bl=ab[n-i+1-j][i];
br=ab[n-i+1][n-i+1-j];
int oth=tl+tr+bl+br;
if(oth>sum)sum=oth,ji=j;
else if(oth==sum&&j<ji)ji=j;
}
add+=sum;
kk+=ji;
}
printf("%d %d\n",ab[(n+1)/2][(n+1)/2]+add,kk);
}
return 0;
}
HDU 4708:Rotation Lock Puzzle的更多相关文章
- HDU 4708 Rotation Lock Puzzle (简单题)
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- HDU 4708 Rotation Lock Puzzle(模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4708 题目大意:给定一个方形矩阵,边长为3-10的奇数.每一圈的数字可以沿着顺时针方向和逆时针方向旋转 ...
- hdu 4708 Rotation Lock Puzzle 2013年ICPC热身赛A题 旋转矩阵
题意:给出一个n*n的矩阵,旋转每一圈数字,求出对角线可能的最大值,以及转到最大时的最小距离. 只要分析每一层就可以了,本来想用地址传递二维数组,发现行不通,改了一下就行了. 这里有个坑,比如: 1 ...
- hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...
- hdu4708 Rotation Lock Puzzle
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDUOJ---(4708)Rotation Lock Puzzle
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Rotation Lock Puzzle
Problem Description Alice was felling into a cave. She found a strange door with a number square mat ...
- Codeforces Round #467 (Div. 2) E -Lock Puzzle
Lock Puzzle 题目大意:给你两个字符串一个s,一个t,长度<=2000,要求你进行小于等于6100次的shift操作,将s变成t, shift(x)表示将字符串的最后x个字符翻转后放到 ...
- hdu 5465 Clarke and puzzle 二维线段树
Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
随机推荐
- bootstrap 时间选择器 datetime
$("'#datetimepicker").datetimepicker({ format: "yyyy-mm-dd hh:ii:ss",//设置时间格式,默认 ...
- <s:select>中list获取action中数据
jsp: <s:select name="cate1.id" list="cate1list" listKey="id" listVa ...
- Socket 编程
- leetcode96 Unique Binary Search Trees
题目: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For e ...
- Leetcode: Palindrome Numbers
Determine whether an integer is a palindrome. Do this without extra space. 尝试用两头分别比较的方法,结果发现无法解决1000 ...
- 转:python webdriver API 之操作测试对象
一般来说,所有有趣的操作与页面交互都将通过 WebElement 接口,包括上一节中介绍的对象定位,以及本节中需要介绍的常对象操作.webdriver 中比较常用的操作元素的方法有下面几个: cle ...
- run()和star()区别
run()和star()区别 run()-->只是thread类的一个普通方法调用 star()-->用来启动线程,实现多线程运行
- BZOJ 4052: [Cerc2013]Magical GCD
以一个数字开头的子序列的gcd种类不会超过logn种,因此去找相同gcd最长的位置,更新一下答案,复杂度O(nlogn^2) #include<cstdio> #include<al ...
- JSon_零基础_007_将JSon格式的"数组"字符串转换为Java对象"数组"
将JSon格式的"数组"字符串转换为Java对象"数组". 应用此技术从一个json对象字符串格式中得到一个java对应的对象. JSONObject是一个“n ...
- paper 86:行人检测资源(上)综述文献【转载,以后使用】
行人检测具有极其广泛的应用:智能辅助驾驶,智能监控,行人分析以及智能机器人等领域.从2005年以来行人检测进入了一个快速的发展阶段,但是也存在很多问题还有待解决,主要还是在性能和速度方面还不能达到一个 ...