摘要: 经典代码 来自YXCYMYXC 1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 double t; 5 int x, y, n; 6 inline double DFS (double a, double b, int n) 7 { 8 double s = 2e18; 9 if (n == 1)10 return max (a, b) / min (a, b);11 for (int i = 1, j = n - 1; i <= j; i ++, j --)12 ... 阅读全文
posted @ 2013-02-04 11:06 Moretimes 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 黑书上猴子内个题 逆向思维真是吊View Code 1 #include <cstdio> 2 #include <cstring> 3 const int N = 500000, M = 500000; 4 int key[M], head[N], next[M], cnt; 5 int a[N], p[N], ans[N]; 6 bool v[N]; 7 inline void add (const int & x, const int & y) 8 { 9 key[cnt] = y;10 next[cnt] = head[x];11 head[x] 阅读全文
posted @ 2013-02-04 11:00 Moretimes 阅读(739) 评论(0) 推荐(0) 编辑
摘要: 想到冗余就差不多了 单调队列View Code 1 #include <cstdio> 2 const int N = 501000; 3 int q[N], loc[N], h, t, n, d, len; 4 inline void INSERT (int x) 5 { 6 while (h <= t && q[t] < x) t --; 7 q[++ t] = x;loc[t] = ++ len; 8 } 9 inline int QUERY (int x)10 {11 int st = 0, ed = t + 1, mid;12 while (s 阅读全文
posted @ 2013-02-04 10:58 Moretimes 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 基于kruscal的贪心 可以有如下推论:两个不同的最小生成树所用的的相同边权的边的数量相同。可以做这样的理解:当进行到选第K大的边时,联通快数是一定的所以的、一定需要K- 1个该权值边 (不知道对不对 欢迎TuneProverbs指正)SB没想好怎么存水体写半天。。。。。。。我是SB 1 #include <cstdio> 2 #include <vector> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 using namespace st 阅读全文
posted @ 2013-02-04 10:55 Moretimes 阅读(328) 评论(0) 推荐(0) 编辑