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? ...
随机推荐
- vmware 共享文件夹 win7 centos6
1. 安装 vmware-tools 1). 右击虚拟机 -- 安装vmware-tools 2). 挂载 mnt /dev/cdrom /mnt 3). yum -y install gcc gcc ...
- CommonJS规范
CommonJS是一种规范,NodeJS是这种规范的实现.CommonJS是一 个不断发展的规范,计划将要包括如下部分: Modules Binary strings and buffers Char ...
- Lucas
C(n,m)%p=C(n%p,m%p)*C(n/p,m/p)%p 迭代递归 n,m非负整数,p质数 证明 最后一个由二项式定理和p进制数性质得出的我并没有看懂...
- 配置文件App.config的使用以及Readonly与Const的对比
以前我们学习的时候都把连接数据库的连接字符串写在一个类中,因为我们的数据库都在自己电脑上.如果更换数据库地址,需要更改这个类,然后重新编译才可以连接到数据库.现在我们需要将连接字符串当道一个文件中,然 ...
- ligerui+json_002_Grid用法、属性总结
原文更全面,地址: http://blog.csdn.net/dxnn520/article/details/8216560 // ================================== ...
- java将数组中的零放到末尾
package com.shb.java; /** * 将数组中的0放到数组的后边,然后原来的非零数的顺序不改变 * @author BIN * */ public class Demo2{ publ ...
- Java -verbose:gc 命令
Java -verbose:gc 中参数-verbose:gc 表示输出虚拟机中GC的详细情况. [Full GC 168K->97K(1984K), 0.0253873 secs] 解读如 ...
- 三层与MVC
三层架构(3-tier architecture) 我们平时总是将三层架构与MVC混为一谈,殊不知它俩并不是一个概念.下面我来为大家揭晓我所知道的一些真相. 首先,它俩根本不是一个概念. 三层架构是一 ...
- 【python】标准库的大致认识
正如那句 Python 社区中很有名的话所说的:“battery included”,Python 的一大好处在于它有一套很有用的标准库(standard library).标准库是随着 Python ...
- 基于ASP.NET MVC 4/5 Razor的模块化/插件式架构实现
概述 在日常开发中, 我们经常谈起模块化/插件化架构,这样可既可以提高开效率,又可以实现良好的扩展性,尤其对于产品化的系统有更好的实用性. 架构 我们采用的是MVC5(本文中介绍的方法对于MVC4也是 ...