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? ...
随机推荐
- docker summary
http://blog.tankywoo.com/docker/2014/05/08/docker-4-summary.html 总结的很好 ----------------------------- ...
- SuSE Apache2 VirtualHost Build
1,linux version:openSuSE 12.1 2,add ServerName to DNS(johv.ts.com ,use the same IP) 3,mkdir /srv/www ...
- 自动备份sqlexpress 数据库脚本
Create PROCEDURE [dbo].[usp_BackupDatabase] @databaseName sysname,@backupPath nvarchar(255), @backup ...
- Orthomcl的详细使用
参考了众多文章并结合实际操作后的感想. 参考:http://www.plob.org/2013/09/18/6174.html 参考:http://www.plob.org/2012/06/12/22 ...
- Highcharts选项配置详细说明文档(zz)
http://www.helloweba.com/view-blog-156.html Highcharts提供大量的选项配置参数,您可以轻松定制符合用户要求的图表,目前官网只提供英文版的开发配置说明 ...
- prezi破解教程
http://www.joenchen.com/archives/998 http://www.joenchen.com/archives/945 Prezi Desktop 4.7.5免注册无时间限 ...
- cluster集群
http://zwfang09.blog.sohu.com/entry/ Cluster 集群 ,群集 --- 负载均衡 LB ,load-balance --- 高可用集群 HA ,High Ava ...
- 三层与MVC
三层架构(3-tier architecture) 我们平时总是将三层架构与MVC混为一谈,殊不知它俩并不是一个概念.下面我来为大家揭晓我所知道的一些真相. 首先,它俩根本不是一个概念. 三层架构是一 ...
- 全志A20芯片用于启动的SD卡的布局
起始 大小 内容 0 8KB 存放分区表等 8 24KB SPL loader 32 512KB u-boot 544 128KB environment 672 352KB 保留 1024 - 用于 ...
- linux强制umount设备的方法
假如挂载时使用了:mount /dev/sda1 /mnt/sda1 #查找占用设备的pid fuser -m /mnt/sda1 #假如此时得到的pid为12345 kill -9 12345 um ...