上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 25 下一页
摘要: 我是求出来所有点的坐标用叉积算的面积……据说可以证明出来S△PQR = S△ABC/7 1 #include <cstdio> 2 #include <cmath> 3 4 struct Point 5 { 6 double x, y; 7 Point( double x = 0, double y = 0 ):x(x), y(y) { } 8 }; 9 10 Point operator+( Point A, Point B ) 11 { 12 return Point( A.x + B.x, A.y + B.y ); 13 } 14 15 P... 阅读全文
posted @ 2013-06-15 20:52 冰鸮 阅读(331) 评论(0) 推荐(0)
摘要: 简单BFS,就是题意理解了好长时间题意:给你三个棋子,要求用最少的步数将这三个棋子移动到同一节点上。每次可以沿一条边移动一个棋子,只有当该边的颜色与另外两个棋子之间的边的颜色相同时才可以移动。 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <queue> 5 6 using namespace std; 7 8 const int MAXN = 60; 9 10 int n;11 int st[3];12 bool vis[626262];13 i 阅读全文
posted @ 2013-06-07 20:43 冰鸮 阅读(262) 评论(0) 推荐(0)
摘要: BFS入门,经典倒水问题,想当年在UVa上做的第一道BFS,今天在POJ上拿来复习一下。拓展队列时注意去掉一些不必要的情况和细节:1.空杯子不能向外倒水2.水从A倒入B后,B水满或不满分情况考虑。据说可以一个式子解决……我是没一个式子解决掉,就分开写了。3.水满的杯子不能再向里倒水 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <queue> 5 6 using namespace std; 7 8 const int MAXN = 30000; 阅读全文
posted @ 2013-06-05 22:01 冰鸮 阅读(303) 评论(0) 推荐(0)
摘要: 之前WA是被这组数据卡掉了:45 15 25 35 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <queue> 5 #include <algorithm> 6 7 using namespace std; 8 9 struct node 10 { 11 int Haash; 12 int use[8]; 13 int count; 14 }; 15 16 17 bool vis[ (1 << 22) + 10 ]; 18 阅读全文
posted @ 2013-05-31 10:35 冰鸮 阅读(578) 评论(0) 推荐(0)
摘要: Manacher算法练笔,O(n)求最长回文子串。参考资料:http://blog.csdn.net/ggggiqnypgjg/article/details/6645824http://www.felix021.com/blog/read.php?2040后缀数组和拓展KMP也可以求,不过时间复杂度都是O(nlogn)。 1 #include 2 #include 3 4 const int MAXN = 110010; 5 6 char s[MAXN]; 7 char str[ MAXN b ? a : b;19 }20 21 void init()22 {23 int ... 阅读全文
posted @ 2013-05-30 11:13 冰鸮 阅读(182) 评论(0) 推荐(0)
摘要: KMP:http://www.matrix67.com/blog/archives/115AC自动机:http://www.cs.uku.fi/~kilpelai/BSA05/lectures/slides04.pdfhttp://blog.csdn.net/niushuai666/article/details/7002823http://www.cppblog.com/mythit/archive/2009/04/21/80633.html 阅读全文
posted @ 2013-05-25 22:29 冰鸮 阅读(146) 评论(0) 推荐(0)
摘要: 二分枚举+KMP之前没注意字典序最小,WA了N次…… 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <algorithm> 5 6 using namespace std; 7 8 const int MAXN = 4010; 9 const int MAXL = 210; 10 11 int N; 12 char str[MAXN][MAXL]; 13 char temp[MAXL]; 14 char anser[MAXL]; 15 int ne 阅读全文
posted @ 2013-05-25 20:34 冰鸮 阅读(174) 评论(0) 推荐(0)
摘要: 线段树点修改+区间合并对于如何查询连续某块的端点和长度还不太熟……但是属于经典常见操作。 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <algorithm> 5 6 using namespace std; 7 8 #define lc rt << 1 9 #define rc rt << 1 | 1 10 #define lson l, m, rt << 1 11 #define rson m + 1, r, 阅读全文
posted @ 2013-05-22 09:50 冰鸮 阅读(184) 评论(0) 推荐(0)
摘要: 裸线段树区间合并,一开始没注意题目细节结果搞麻烦了……给你四种操作,每种操作按它的要求输出结果。1.Reset Reset all memory units free.Reset 释放所有的内存2.New x Allocate a memory block consisted of x continuous free memory units with the least start numberNew x 申请一个包含x个连续内存单元的内存块,起始地址编号最小3.Free x Release the memory block which includes unit xFree x 释放包含. 阅读全文
posted @ 2013-05-21 22:55 冰鸮 阅读(373) 评论(0) 推荐(0)
摘要: 裸线段树区间合并,题目本身不难,就是细节处理比较麻烦。因为涉及到异或运算,所以连续0和连续1的个数都要记录一下。操作的懒惰标记我只用了一个flag,注意flag更新时的细节,我分了三种情况:flag == -1 或者 当前操作为0或1:更新时直接赋值。因为0, 1操作都可以直接覆盖前面的操作。flag == 0或1,当前操作为2(xor):flag ^= 1。前面标记过0或1,当前操作为异或,那么改变flag标记flag == 2,当前操作为2(xor): flag = -1。前面只出现过异或运算,没出现过0,1运算。因为异或两次相当于没异或,所以清除标记即可。 1 #include < 阅读全文
posted @ 2013-05-20 21:03 冰鸮 阅读(268) 评论(0) 推荐(0)
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 25 下一页