“今日头条杯”首届湖北省大学程序设计竞赛--F. Flower Road
题目链接:点这
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
-->
输入
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的更多相关文章
- “今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--E. DoveCCL and Resistance
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/D来源:牛客网 题目描述 ...
- A. Srdce and Triangle--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
如下图这是“今日头条杯”首届湖北省大学程序设计竞赛的第一题,作为赛后补题 题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 Let be a regualr tr ...
- I. Five Day Couple--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/H来源:牛客网 题目描述 ...
- D. Who killed Cock Robin--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 由于系统限制,C题无法在此评测,此题为现场赛的D题 Who killed Cock Robin? I, ...
- H. GSS and Simple Math Problem--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 Given n positive integers , your task is to calculat ...
- D. Who killed Cock Robin 湖北省大学程序设计竞赛
链接:https://www.nowcoder.com/acm/contest/104/C来源:牛客网 The Sparrow is for trial, at next bird assizes,w ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- 【数论&想法题】小C的问题 @"科林明伦杯"哈尔滨理工大学第八届程序设计竞赛
Time Limit: 1000 MS Memory Limit: 256000 K Description 小C是一个可爱的女孩,她特别喜欢世界上最稳定的图形:三角形.有一天她得到了n根木棍,她把这 ...
- 2018今日头条杯 E-Jump a Jump
Problem E. Jump A JumpInput file: standard inputOutput file: standard outputTime limit: 1 secondsMemor ...
随机推荐
- Android 模糊搜索rawquery bind or column index out of range: handle 0x2fb180 报错
做模糊搜索时,出现了 bind or column index out of range: handle 0x2fb180 报错 public Cursor getTitle(String word ...
- MySql插入数据成功但是报[Err] 1055
1.问题: 这两天做insert操作,mysql版本是5.7,insert后虽然成功了,但是会报一个[Err] 1055的错误.具体如下: 2.解决方案: linux环境下,vim到my.cnf,添加 ...
- jmeter之-非GUI模式&登录实战
1.执行测试脚本 jmeter -n -t JMeter分布式测试示例.jmx 2.指定结果文件及日志路径 jmeter -n -t JMeter分布式测试示例.jmx -l report\01-re ...
- [六省联考2017]分手是祝愿 题解(期望dp)
题目描述 B 君在玩一个游戏,这个游戏由 n 个灯和 n 个开关组成,给定这 n 个灯的初始状态,下标为从 1 到 n 的正整数. 每个灯有两个状态亮和灭,我们用 1 来表示这个灯是亮的,用 0 表示 ...
- Nginx在Windows平台的配置
Nginx在Windows平台的配置 能够使用Nginx搭建Tomcat集群,并完成负载均衡. 1.什么是Nginx 2.为什么使用Nginx 背景: 互联网飞速发展的今天,大用户量高并发已经成为互联 ...
- 栈Stack --- 数组实现
栈最大的一个特点就是先进后出(FILO—First-In/Last-Out). /** * 栈:后进先出 * Created by fred on 2018/7/31. */ public class ...
- C语言博客作业02
2.1 一.请仔细阅读<提问的智慧>,用自己的话描述你的收获,并举例子说明应该如何提问. 答:1.提问是思考的另一种方式,一个好的提问能体现出我们在认真的,聪明的思考; 2.做什么事情都要 ...
- Optional int parameter 'pId' is present but cannot be translated into a null value due to being declared as a primitive type.
接口测试的时候遇到了一个问题,导致测试阻断了好久,在此记录,谨防忘记. 具体报错如下: Optional int parameter 'pId' is present but cannot be tr ...
- Debug模式的三种配置方法
使用`app.config.from_object`的方式加载配置文件: 1. 导入`import config`.2. 使用`app.config.from_object(config)`. ### ...
- Python之实现一个优先级队列
问题 怎样实现一个按优先级排序的队列? 并且在这个队列上面每次 pop 操作总是返回优先级最高的那个元素 解决方案 下面的类利用 heapq 模块实现了一个简单的优先级队列: import heapq ...