题目链接:点这

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. 2019 TCO Round 1B——[ 状压DP ]

    第一题是 EllysSki . 题意:给n个数,求两个方向的最长递减区间. 可以O(n). #include<cstdio> #include<cstring> #includ ...

  2. Android学习--写一个发送短信的apk,注意布局文件的处理过程!!!

    刚开始写Android程序如图发现使用了findViewById方法之后输出的话居然是null(空指针错误),也就是说这个方法没有成功.网上说这样写是在activity_main .xml去找这个ID ...

  3. python pymouse用法记录

    from pymouse import PyMouse m = PyMouse() m.position()#获取当前坐标的位置 m.move(x,y)#鼠标移动到xy位置 m.click(x,y)# ...

  4. ajax 通过回调函数获取异步数据

    这里不再解释什么是 ajax,以及什么是异步的问题. 我们直接来问题,这里采用 jQuery 的 ajax 方法来获取数据. 先来看代码: $(function () { let db = ''; $ ...

  5. UVA_548Tree

    这是一个很经典的建树,然而当时不会!!!! 给你一个中序和后序 先建一个二叉树,然后找最优解(最优解就是一个叶子节点到根节点权值最小, 同时本身权值最小) //生成一棵树 int build(int ...

  6. 时间同步服务器NTP

    NTP服务器        NTP(Network Time Protocol)[网络时间协议],它是用来同步网络中各个计算机的时间的协议,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒, ...

  7. 【题解】Crossing River

    题目描述 几个人过河,每次过两人一人回,速度由慢者决定,问过河所需最短时间. 输入格式 输入t组数据,每组数据第1行输入n,第2行输入n个数,表示每个人过河的时间. 输出格式 输出t行数据,每行1个数 ...

  8. 在规定的时间内出现动画.html

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. 使用pip安装python模块和包

    点击进入幕布视图浏览 https://mubu.com/doc/a8VGCUfqqw 五.使用pip安装python第三方库. pip的常用命令 方式一:在线安装 1.进入命令行 2.敲入pip命令: ...

  10. 移动端mintUI mt-datetime-picker 组件使用详解

    <mt-datetime-picker v-model="pickerVisible" //绑定的数据值 ref="pickerData" // 点击触发 ...