题目链接:点这

github链接:(包含数据和代码,题解):点这

链接:https://www.nowcoder.com/acm/contest/104/E
来源:牛客网

题目描述

(受限于评测机,此题数据范围与现场赛不一致,请谅解)

Once upon a time, there was a beautiful princess named TQM, and a handsome prince named GSS. One day, the prince would like to visit the princess. While in front of the princess' house, there was a flower-beds with blooming flowers. The prince was supposed to go through the flower-beds choosing the best ``Flower Road''.

Here is the task. The flower-beds is presented by a matrix with integers on each grid representing the princess' satisfaction of the flowers on it. Now, the prince was on the top left point (1, 1) and the princess was on the bottom right point (N, N). While the princess didn't want this to be so easy, she operated M times ``rotation'' on the flower-beds according to the order. Each time, she would choose a matrix whose top left point was . Then, four disjoint parts of the matrix whose length of size was rotated clockwise. Here is an example to make the ``rotation'' clearly.

Then, your task is to help the prince to choose a best ``Flower Road'' after these operations with the largest sum of the satisfaction. By the way, the prince will take the shortest way, which means he will only go down (from point (x, y) to point (x+1, y)) and right (from point (x, y) to point (x, y+1)).

输入描述:

The first line of input contains two integers, N (

) and M (

), indicating the numbers N and M described above. Then N lines follow, and each line N integers, representing the matrix. Then M lines follow, each line has three integers 

, where x

i

 and y

i

 are coordinates of the top right point of i-th rotation matrix, 

th - side length of the matrix.

输出描述:

Output the max sum of the satisfaction.

输入例子:
4 1
1 2 5 6
3 4 7 8
13 14 9 10
15 16 11 12
1 1 2
输出例子:
81

-->

示例1

输入

4 1
1 2 5 6
3 4 7 8
13 14 9 10
15 16 11 12
1 1 2

输出

81

意思就是:给你个矩阵,中间有m个操作,选择矩阵,本来以为会卡时间,但是好像并没有,直接旋转,然后Dp
/*
author:gsw
data:2018.05.02
link:https://www.nowcoder.com/acm/contest/104/E
accout:tonygsw
*/
#define ll long long
#define IO ios::sync_with_stdio(false);
#define maxn 1505 #include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<vector>
using namespace std; int n,m,x,y,l;
ll dp[maxn][maxn];
int value[maxn][maxn]; void init()
{
memset(dp,,sizeof(dp));
} int DP()
{
for(int i=;i<=n;i++)
for(int j=;j<=n;j++)
dp[i][j]=max(dp[i][j],max(dp[i-][j]+value[i][j],dp[i][j-]+value[i][j]));
printf("%lld\n",dp[n][n]);
}
inline void xz(int x,int y,int l)
{
for(int i=;i<l;i++)
{
for(int j=;j<l;j++)
{
int tem=value[x+i][y+j];
//cout<<tem<<" ---------"<<endl;
value[x+i][y+j]=value[x+i+l][y+j];
value[x+i+l][y+j]=value[x+i+l][y+j+l];
value[x+i+l][y+j+l]=value[x+i][y+j+l];
value[x+i][y+j+l]=tem;
}
}
}
int main()
{
init();
scanf("%d%d",&n,&m);
//cout<<n<<" "<<m<<"-----------"<<endl;
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
scanf("%d",&value[i][j]);
}
}
//cout<<n<<" "<<m<<"-----------"<<endl;
for(int i=;i<m;i++)
{
scanf("%d%d%d",&x,&y,&l);
xz(x,y,l);
}
/*
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
cout<<value[i][j]<<" ";
cout<<endl;
}*/
DP();
}

“今日头条杯”首届湖北省大学程序设计竞赛--F. Flower Road的更多相关文章

  1. “今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--E. DoveCCL and Resistance

    题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/D来源:牛客网 题目描述 ...

  2. A. Srdce and Triangle--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)

    如下图这是“今日头条杯”首届湖北省大学程序设计竞赛的第一题,作为赛后补题 题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 Let  be a regualr tr ...

  3. I. Five Day Couple--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)

    题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/H来源:牛客网 题目描述 ...

  4. D. Who killed Cock Robin--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)

    题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 由于系统限制,C题无法在此评测,此题为现场赛的D题 Who killed Cock Robin? I, ...

  5. H. GSS and Simple Math Problem--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)

    题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 Given n positive integers , your task is to calculat ...

  6. D. Who killed Cock Robin 湖北省大学程序设计竞赛

    链接:https://www.nowcoder.com/acm/contest/104/C来源:牛客网 The Sparrow is for trial, at next bird assizes,w ...

  7. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  8. 【数论&想法题】小C的问题 @"科林明伦杯"哈尔滨理工大学第八届程序设计竞赛

    Time Limit: 1000 MS Memory Limit: 256000 K Description 小C是一个可爱的女孩,她特别喜欢世界上最稳定的图形:三角形.有一天她得到了n根木棍,她把这 ...

  9. 2018今日头条杯 E-Jump a Jump

    Problem E. Jump A JumpInput file: standard inputOutput file: standard outputTime limit: 1 secondsMemor ...

随机推荐

  1. subsequence 1

    题目链接 题意:给你两个字符串都是数字,让你求第一个字符串的子序列中大于第二个字符串的个数. 思路:dp[i][j] 表示 str1的前i个,匹配 str2的前 j 个的种类数,那么 if(s[i] ...

  2. http协议和file协议的区别

    1.在本地直接使用浏览器打开  html文件 和 通过本地服务器打开  html文件  有什么区别呢.  https://segmentfault.com/q/1010000006554881/a-1 ...

  3. 探索Redis设计与实现4:Redis内部数据结构详解——ziplist

    本文转自互联网 本系列文章将整理到我在GitHub上的<Java面试指南>仓库,更多精彩内容请到我的仓库里查看 https://github.com/h2pl/Java-Tutorial ...

  4. Android如何正确引用其它jar包 (转)

    转:http://blog.csdn.net/liranke/article/details/17226083 Android项目常常需要引用自定义的或者外部的jar包,这里提供一些经验,供参考. 一 ...

  5. 用JOptionPane类实现各种对话框

    用JOptionPane类实现各种对话框 运行结果: 下面部分参考: JOptionPane类提示框的一些常用的方法 - - ITeye博客  http://847353020-qq-com.itey ...

  6. LeetCode刷题笔记-递归-反转二叉树

    题目描述: 翻转一棵二叉树. 解题思路: 1.对于二叉树,立马递归 2.先处理 根节点,不需改动 3.处根的左子树和右子树需要交换位置 4.递归处理左子树和右子树.步骤见1-3步 Java代码实现: ...

  7. java多线程学习笔记(四)

    上一节讲到Synchronized关键字,synchronized上锁的区域:对象锁=方法锁/类锁 本节补充介绍一下synchronized锁重入: 关键字synchronized拥有锁重入的功能,也 ...

  8. Apache—httpd服务创建个人用户主页功能

    创建个人用户主页功能 第1步:开启个人用户主页功能  UserDir disabled前加# UserDir public_html 去掉前面# UserDir参数表示的是需要在用户家目录中创建的网站 ...

  9. css篇-页面布局-三栏布局

    页面布局 题目:假设高度已知,请写出三栏布局,其中左栏.右栏宽度各为300px,中间自适应. 1)浮动 2)绝对定位 3)Flexbox 4)表格布局 5)网格布局(CSS3的Grid布局) 代码: ...

  10. 挂载时出现mount: RPC: Unable to receive; errno = Connection refused错误的解决方法

    当我们在做NFS开发板下挂载时,经常会出现mount: RPC: Unable to receive; errno = Connection refused的错误,连接被拒绝了,到底是什么原因呢? 这 ...