题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4824

题意:中文,不解释

题解:双调欧几里德旅行商问题,具体可看dp双调欧几里德旅行商,这里注意的是起点为0,0。

 #include<cstdio>
#define FFC(i,a,b) for(int i=a;i<=b;i++)
const int maxn=,inf=1e9;
int dp[maxn][maxn],t,n;
struct node{int x,y;}g[maxn];
int abs(int a){return a>?a:-a;}
int Min(int a,int b){return a>b?b:a;}
int dis(int i,int j){
int s1=abs(g[i].x-g[j].x)*+abs(g[i].y-g[j].y),s2;
int max=g[i].y>g[j].y?g[i].y:g[j].y,min=Min(g[i].y,g[j].y);
s2=abs(g[i].x-g[j].x)*+-max+min;
return s1>s2?s2:s1;
}
int fuck(int n){
FFC(i,,n)dp[i][i-]=inf;
dp[][]=,dp[][]=dis(,);
FFC(i,,n)FFC(j,,i-)
dp[i][j]=dp[i-][j]+dis(i-,i),dp[i][i-]=Min(dp[i][i-],dp[i-][j]+dis(j,i));
return dp[n][n-]+dis(n,n-);
}
int main(){
scanf("%d",&t);
g[].x=g[].y=;
while(t--){
scanf("%d",&n);
FFC(i,,n+)scanf("%d%d",&g[i].x,&g[i].y);
printf("%d\n",fuck(n+)+n*);
}
return ;
}

hdu_4824_Disk Schedule(dp)的更多相关文章

  1. Codeforces 1324E Sleeping Schedule DP

    题意 给你一个长度为\(n\)的数组\(a\)和3个数字\(h,l和r\).\(t\)初始为0,每次可以使\(t=(t+a_i) \% h\)或者\(t=(t+a_i-1)\%h\),如果这时\(t\ ...

  2. 2014百度之星第二题Disk Schedule(双调欧几里得旅行商问题+DP)

    Disk Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) To ...

  3. HDU 4175 Class Schedule (暴力+一点dp)

    pid=4175">HDU 4175 题意:有C座楼,每座楼有T个教室.一个人须要訪问C个教室.每座楼仅仅能訪问一个教室. 訪问教室须要消耗能量,从x点走到y点须要消耗abs(x-y) ...

  4. 【dp】Arrange the Schedule

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3538 题意:如题. 题解: 假如 一组数据 ...(n1)A.. ...

  5. UVA - 1025 A Spy in the Metro[DP DAG]

    UVA - 1025 A Spy in the Metro Secret agent Maria was sent to Algorithms City to carry out an especia ...

  6. UVA1025---A Spy in the Metro(DP)

    http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35913 Secret agent Maria was sent to Alg ...

  7. 百度之星资格赛——Disk Schedule(双调旅行商问题)

    Disk Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) To ...

  8. 【UVA 1380】 A Scheduling Problem (树形DP)

    A Scheduling Problem   Description There is a set of jobs, say x1, x2,..., xn <tex2html_verbatim_ ...

  9. poj 3616 Milking Time(dp)

    Description Bessie ≤ N ≤ ,,) hours (conveniently labeled ..N-) so that she produces as much milk as ...

随机推荐

  1. 301跳转:IIS服务器网站整站301永久重定向设置方法(阿里云)

    欢迎来到重庆SEO俱乐部:搜索引擎优化学习交流QQ群224306761. 承接:seo优化.网站建设.论坛搭建.博客制作.全网营销 博主可接:百度百家.今日头条.一点资讯等软文发布,有需要请联系PE! ...

  2. 【转】母函数(Generating function)详解 — TankyWoo(红色字体为批注)

    母函数(Generating function)详解 - Tanky Woo 在数学中,某个序列的母函数(Generating function,又称生成函数)是一种形式幂级数,其每一项的系数可以提供 ...

  3. angularjs中sortable的使用

    将每个li并列排序,同时可以实现拖拉排序功能 html: js:使用的插件:html.sortable.angularjs,html.sortable.js 实现的效果: 通过js中sortableO ...

  4. python zipfile 文件压缩和文件

    文件压缩 zipfile_obj = zipfile.ZipFile(zipfile_objpath, 'a', zipfile.ZIP_DEFLATED) for dirpath, dirnames ...

  5. 【留念贴】Android开发——计算器

    [过程] 在电商学霸&&代码女神XuFei的影响下,接触到了关于Android客户端的一些开发,第一次在Android平台搞出了一个App,真的是激动不已,所以必须开个留念贴记录一下. ...

  6. 朴素贝叶斯算法 & 应用实例

    转载请注明出处:http://www.cnblogs.com/marc01in/p/4775440.html 引 和师弟师妹聊天时经常提及,若有志于从事数据挖掘.机器学习方面的工作,在大学阶段就要把基 ...

  7. 大数据时代之hadoop(六):hadoop 生态圈(pig,hive,hbase,ZooKeeper,Sqoop)

    hadoop是有apache基金会所开发的分布式系统基础架构,其主要提供了两方面的功能:分布式存储和分布式计算. 其中分布式存储是分布式计算的基础,在hadoop的实现里面,提供了分布式存储的接口,并 ...

  8. 《JS权威指南学习总结--1.1语言核心》

    1.1语言核心 --本节主要介绍<js权威指南>基础部分各章讲解内容和一些简单的示例 本小节内容: 一.第二章讲解js注释.分号和Unicode,第三章主要讲解js变量和赋值 简单示例: ...

  9. php 语音参考

    如果文件内容是纯 PHP 代码,最好在文件末尾删除 PHP 结束标记.这可以避免在 PHP 结束标记之后万一意外加入了空格或者换行符,会导致 PHP 开始输出这些空白,而脚本中此时并无输出的意图.   ...

  10. 主题: jQuery异步调用KindEditor无法赋值【解决】

    KindEditor.ready(function (K) { window.editor1 = K.create('#tjssjs', { width: '480px', height: '150p ...