“今日头条杯”首届湖北省大学程序设计竞赛--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 ...
随机推荐
- python 网络编程:socket(二)
上节地址:Python网络编程:socket 一.send和sendall区别 send,sendall ret = send('safagsgdsegsdgew') #send 发送 ...
- CSS 提示工具(Tooltip)
CSS 提示工具(Tooltip) 本文为大家介绍如何使用HTML和CSS来实现提示工具, 提示工具在鼠标移动到制定元素后触发,先看下面示例: 1.基础提示工具代码如下: <!doctye ht ...
- 个人笔记 - C++相关收藏
一.文件操作 1.C++从txt文件中读取二维的数组
- (8)C++ 内存模型与名称空间
一.单独编译 头文件 不要将函数定义或者变量声明放到头文件中,引入多个文件时可能会造成同一个函数定义多次 引入头文件 #include "文件名" File1.h #ifndef ...
- RFC6241 NETCONF
概述 NETCONF = The Network Configuration Protocol SDN = Software Define Network NETCONF协议分为传输层.消息层.操作层 ...
- upc组队赛1 小C的数学问题【单调栈】(POJ2796)
小C的数学问题 题目描述 小C是个云南中医学院的大一新生,在某个星期二,他的高数老师扔给了他一个问题. 让他在1天的时间内给出答案. 但是小C不会这问题,现在他来请教你. 请你帮他解决这个问题. 有n ...
- qrcode-使用
安装 composer require endroid/qrcode namespace App\Http\Controllers\Admin; use Endroid\QrCode\QrCode; ...
- 洛谷P1629 邮递员送信 最短路-Djistra
先上一波题目qwq https://www.luogu.org/problem/P1629· 复习了一波 dijstra 的 priority_queue(优先队列)优化的写法 tips: 求单项路中 ...
- Jmeter脚本如何在Linux通过no GUI的方式运行 命令行传递参数
本文主要介绍Jmeter脚本如何在Linux通过no GUI的方式运行.总共分三部分: 1.Linux下JDK的安装及环境变量的配置 2.Linux下Jmeter的安装及环境变量的配置 3.运行结果的 ...
- vue.js实现用户评论、登录、注册、及修改信息功能
vue.js实现用户评论.登录.注册.及修改信息功能:https://www.jb51.net/article/113799.htm