A

题意:有n个机场处于一直线上,可两两到达,每个机场只可能属于两家公司中的一家(用0,1表示),现在要从a机场到b机场,可任意次转机。若机场i与机场j从属同一公司,则费用为0,否则费用为1。问最小费用?

分析:题目看懂就行了,起点和终点相同答案就是0,否则就是1

B

题意:和Wannafly Union Goodbye 2016的B题十分类似,分治搞

C

题意:求x,y,z使得对于给定的n(1≤n≤10^4) 2/n=1/x+1/y+1/z成立

分析:数学

  目标是把2/n裂成3项

  2/n=1/n+1/n

     =1/n+(n+1)/(n*(n+1))

     =1/n+1/(n+1)+1/[n*(n+1)]

  注意n=1时候无解

D

题意:有根树以1为根节点,问如何选择两个不同的节点i和j,使得两棵子树不相交,同时两子树上的节点val和最大?

分析:树形dp

  先跑一遍dfs,算出每个节点的sum[i],顺便求出f[i]表示以i为根的子树中,sum[k]最大的那个小子树的sum值

  然后再跑一遍dfs,由底向上算出每个节点k内的最大答案,具体的就是对于k的所有儿子,取f[u]最大的两个更新答案

E

题意:给你n个数(n<=1000),它们都是1~8,选出一个最长的序列使得该序列满足两个条件:1、所有相同的数字必须连续出现 2、设sum[i]为数字i出现的个数,要求任意i,j,abs(sum[i]-sum[j])<=1

分析:二分答案+状压DP

  可以先二分len表示每个数字出现次数的最小值,那么每个数字出现次数为len或者len+1

  预处理出last[i][j]表示从位置i往前,连续j个数字a[i],到位置last[i][j]为止

  f[i][j][k]表示[前i个数,状态为j(0~2^8-1表示每个数字是否取过),有k个len+1 ]这种情况是否存在

  转移的时候有三种,一种是i直接由i-1转移得到,第二种是i向前len,第三种是i向前len-1

  最后刷一遍统计最大值

  还有注意特判n=1,以及二分出来的l(有可能l没有check就退出二分了)

  细节比较多,调了很久,debug能力和全面考虑问题还有待提高

  

Codeforces Round #384(div 2)的更多相关文章

  1. Codeforces Round #384 (Div. 2) E. Vladik and cards 状压dp

    E. Vladik and cards 题目链接 http://codeforces.com/contest/743/problem/E 题面 Vladik was bored on his way ...

  2. Codeforces Round #384 (Div. 2)D - Chloe and pleasant prizes 树形dp

    D - Chloe and pleasant prizes 链接 http://codeforces.com/contest/743/problem/D 题面 Generous sponsors of ...

  3. Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题

    C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...

  4. Codeforces Round #384 (Div. 2)B. Chloe and the sequence 数学

    B. Chloe and the sequence 题目链接 http://codeforces.com/contest/743/problem/B 题面 Chloe, the same as Vla ...

  5. Codeforces Round #384 (Div. 2) A. Vladik and flights 水题

    A. Vladik and flights 题目链接 http://codeforces.com/contest/743/problem/A 题面 Vladik is a competitive pr ...

  6. Codeforces Round #384 (Div. 2) C. Vladik and fractions(构造题)

    传送门 Description Vladik and Chloe decided to determine who of them is better at math. Vladik claimed ...

  7. Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)

    传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...

  8. Codeforces Round #384 (Div. 2) 734E Vladik and cards

    E. Vladik and cards time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #384 (Div. 2)D-Chloe and pleasant prizes

    D. Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabytes input ...

随机推荐

  1. 4.在MVC中使用仓储模式进行增删查改

    原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-using-the-repository-pattern-in-mvc/ 系列目录: ...

  2. Nancy之大杂烩

    Nancy关于Hosting的简单介绍 一. Nancy之基于Nancy.Hosting.Aspnet的小Demo 二.Nancy之基于Nancy.Hosting.Self的小Demo 三.Nancy ...

  3. GridView的使用(高度封装,不怎么灵活,repeat可替代)

    GridView的使用 首先,gridview是封装好的,直接在设计界面使用,基本不需要写代码: 一.绑定数据源 GridView最好与LinQDatasourse配合使用,相匹配绑定数据: 二.样式 ...

  4. UEditor百度富文本编辑器--preview在线预览时头部被挡住的解决方案

    问题截图: 正常情况应该是如下显示: 解决方案: 1.打开ueditor/dialogs/preview/preview.html 2.找到body节点下面这一句 document.getElemen ...

  5. UML类图几种关系的总结

    在UML类图中,常见的有以下几种关系: 泛化(Generalization),  实现(Realization),关联(Association),聚合(Aggregation),组合(Composit ...

  6. 初识ASP.NET MVC

    我们首先从创建ASP.NET MVC项目开始.打开Visual Studio,在文件菜单中选择新建-> 项目,然后在模板中选择Web,接着选择ASP.Net Web应用程序,更改项目名称,点击确 ...

  7. 9.2.3 .net core 通过TagHelper封装控件

    .net core 除了继续保留.net framework的HtmlHelper的写法以外,还提供了TagHelper和ViewComponent方式生成控件. 我们本节说的是使用TagHelper ...

  8. windows go安装

    1.安装git 因为golang是通过git来管理远程包的,所以我们首先要安装git,下载地址:http://www.git-scm.com/download/. git安装比较简单,直接下一步即可( ...

  9. px-rem px转换为rem的工具

    将px转换为rem的工具,github地址:https://github.com/finance-sh/px-rem 将px转换为rem的工具 怎样转换静态文件 安装: npm install px- ...

  10. iOS 对模型对象进行归档

    归档是指一种形式的序列化,专门编写用于保存数据的任何对象都应该支持归档.使用对模型对象进行归档的技术可以轻松将复杂的对象写入文件,然后再从中读取它们. 只要在类中实现的每个属性都是标量或者都是遵循NS ...