摘要: 明天补上。。。这道题的思路确实很精致。考虑到连的边肯定不会是一个环,所以至少有一个断点。于是,可以枚举这个断点。断点一确定,那么连边的走向也就确定了。用D【i】表示由i开始可以到达的最远点即可。对于中间被断开的点,保存[1,left],[right,n]即可。#include #include #i... 阅读全文
posted @ 2015-02-12 23:43 chenjunjie1994 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 一水,最小生成树,缓解心情#include #include #include #include using namespace std;const int inf=(1lowest[k]){ minc=lowest[k]; pos=k; } } // coutmap[pos][k]) ... 阅读全文
posted @ 2015-02-12 17:05 chenjunjie1994 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 把边按权值排序后,就相当于求一个子序列以1开始和以n结束。由于边权递增,而且相差>=k,所以,边的顺序也必定是递增的。知道,当处理一条出边时,必定是从入边选择一条最优的边,考虑两个因素,入边的权值和入边以前的总的代价。优化很容易想到,每个结点维护一个数组,就不需要从头扫描边数组了。但这个维护的结点的... 阅读全文
posted @ 2015-02-12 15:45 chenjunjie1994 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 范围 内的斐波那契的数不多,求出范围内的数,再暴力枚举即可。#include #include #include #include #include using namespace std;#define N 1000000000__int64 foci[200];int fc=0,cnt;__i... 阅读全文
posted @ 2015-02-12 12:10 chenjunjie1994 阅读(120) 评论(0) 推荐(0) 编辑