“今日头条杯”首届湖北省大学程序设计竞赛--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 ...
随机推荐
- 自己动手写ORB特征
通过一些简单的算法修改,使ORB的提取效率加速了5.8倍.编译该程序需要CPU支持SSE指令集. 如果我们能够对特征提取部分进一步并行化处理,则算法还可以有加速的空间. // // Created b ...
- Linux下dd和od命令备份查看硬盘mbr,并用vim修改!
主引导记录(Master Boot Record,MBR),位于一个硬盘的0柱面.0盘面.1扇区,共512字节.具体划分依次为:引导代码区440字节.磁盘签名4字节.空白(Ox0000)2字节.MBR ...
- python count()函数
Python 元组 count() 方法用于统计某个元素在元祖,列表,字符串中出现的次数.可选参数为在字符串搜索的开始与结束位置. 参数 sub -- 搜索的子字符串 start -- 字符串开始搜索 ...
- Jmeter 5.1命令行执行bat文件
一.编写run_jmeter,bat @echo off::设置参数::参考命令:jmeter -n -t d:\123.jmx -l result.jtl -e -o d:\report\repor ...
- 指向自身类型的成员指针的初始化,this不属于类对象的一部分
有下面的一个简单的类: class CNullPointCall{public: static void Test1(); void Test2(); void Test3(int ...
- USB3.0 对 2.4G WiFi 影响
Intel的一篇白皮书<USB 3.0 Radio Frequency Interference Impact on 2.4 GHz Wireless Devices>中即清楚地指出,US ...
- 12. MySQL简单使用
关于MySQL的使用,大家可以去网上看相关教程,但是为了保证阅读的连贯性,这里会做简单介绍. 创建数据库 我们双击刚刚新建的数据库,然后双击mysql,点击新建查询,可以在编辑器里面输入一些mysql ...
- Leetcode代码复盘_动态规划
动态规划中包含3个重要的概念: 1.最优子结构 2.边界 3.状态转移公式 以跳台阶为例,最优子结构为f(10)=f(9) + f(8),边界是f(1)=1, f(2)=2,状态转移公式f(n)=f( ...
- 2.5 Nginx服务器基础配置实例
pay平台nginx配置文件详解 ###全局块### user www www; #指定运行worker process 的用户和用户组 worker_processes 4; #指定Nginx开 ...
- 高级UI晋升之自定义View实战(五)
更多Android高级架构进阶视频学习请点击:https://space.bilibili.com/474380680本篇文章将从自定义View利器Canvas和Paint来进行详解 一.Canvas ...