10 2014 档案

摘要:https://codility.com/programmers/challenges/magnesium2014图形上的DP,先按照路径长度排序,然后依次遍历,状态是使用到当前路径为止的情况;每个节点记录以该节点结束的最长路径,这样加入新的路径时去更新。注意路径是双向的~#include #inc... 阅读全文
posted @ 2014-10-30 00:07 阿牧遥 阅读(174) 评论(0) 推荐(0)
摘要:https://www.hackerrank.com/contests/101hack/challenges/similarpair这题有点意思。在DFS遍历的过程中,用线段树去记录和查询区间的点数。要注意线段树的这种写法里面,index和begin,end是融为一体的,索引其实就决定了begin和... 阅读全文
posted @ 2014-10-24 22:46 阿牧遥 阅读(465) 评论(0) 推荐(0)
摘要:http://codevs.cn/problem/1081/#include #include #include using namespace std;const int MAXN = 100000;struct Line { int left, right; int n;};Line... 阅读全文
posted @ 2014-10-19 10:47 阿牧遥 阅读(181) 评论(0) 推荐(0)
摘要:http://codevs.cn/problem/1080/#include #include #include using namespace std;const int MAXN = 100000;struct Line { int left, right; int n;};Line... 阅读全文
posted @ 2014-10-19 10:40 阿牧遥 阅读(206) 评论(0) 推荐(0)
摘要:https://code.google.com/codejam/contest/4214486/dashboard#s=p0排列组合。DP递推式,如下代码。dp[m][n]表示长度为n的字符串里有m个字符,那么可以先用m-1个字符拼一个长度为n-1的字符串,然后再C(n,1)里面挑一个放最后一个字符... 阅读全文
posted @ 2014-10-18 22:53 阿牧遥 阅读(151) 评论(0) 推荐(0)
摘要:https://codility.com/demo/take-sample-test/max_double_slice_sum两个最大子段和相拼接,从前和从后都扫一遍。注意其中一段可以为0。还有最后和最前面一个不可能取到~#include using namespace std;int soluti... 阅读全文
posted @ 2014-10-14 12:24 阿牧遥 阅读(262) 评论(0) 推荐(0)