上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 26 下一页
摘要: 简单的计算几何;可以把0-2*pi分成几千份,然后找出最小的;也可以用三分; 1 #include 2 #include 3 #include 4 #define pi acos(-1) 5 #define eps 1e-6 6 using namespace std; 7 8 struct node 9 {10 double x,y;11 node(double x=0,double y=0):x(x),y(y){ }12 bool operator0)return length(v3);40 else return fabs(cross(v1,v2))/l... 阅读全文
posted @ 2013-11-01 21:01 Yours1103 阅读(130) 评论(0) 推荐(0) 编辑
摘要: splay的题;学习白书上和网上的代码敲的; 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int n,m; 7 struct node 8 { 9 node *ch[2]; 10 int s,v; 11 int flip; 12 node(int v):v(v) 13 { 14 ch[1]=ch[0]=NULL; 15 s=1; 16 flip=0; 17 } 18 voi... 阅读全文
posted @ 2013-11-01 18:58 Yours1103 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 用可重集;首先按照x排好序,然后只要找到下界,插入,然后把y坐标大于它的都删掉就行; 1 #include 2 #include 3 using namespace std; 4 5 struct node 6 { 7 int a,b; 8 bool operators;16 multiset::iterator it;17 18 int main()19 {20 int t,n,ca=1;21 node p;22 scanf("%d",&t);23 while(t--)24 {25 s.clear();26 ... 阅读全文
posted @ 2013-10-31 22:42 Yours1103 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 基于hash的LCP算法; 1 #include 2 #include 3 #include 4 #define maxn 40010 5 using namespace std; 6 7 const int x=123; 8 int n,m,pos; 9 unsigned long long h[maxn],xp[maxn],hash[maxn];10 int rank[maxn];11 12 bool cmp(const int &a,const int &b)13 {14 return hash[a]=m)pos=max(pos,rank[i]);31 }32 ... 阅读全文
posted @ 2013-10-31 22:18 Yours1103 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 花了一个半小时的时间,终于把这个题目给A了;知道用后缀数组后,这个题目其实不难;就一个二分;用白书当模板其实还挺不错的! 1 #include 2 #include 3 #include 4 #define maxn 110009 5 using namespace std; 6 7 int s[maxn]; 8 int sa[maxn],t[maxn],t2[maxn],c[maxn],n; 9 10 void build_sa(int m) 11 { 12 int *x=t,*y=t2; 13 for(int i=0; i=0; i--)sa[--c[... 阅读全文
posted @ 2013-10-31 17:52 Yours1103 阅读(556) 评论(0) 推荐(0) 编辑
摘要: 对于两只狗在经过拐点之前,他们的运动可以简化为一只狗不动,另一只狗以他们的相对速度运动; 1 #include 2 #include 3 #include 4 #define maxn 66 5 #define eps 1e-6 6 using namespace std; 7 8 struct node 9 {10 double x,y;11 node(double x=0,double y=0):x(x),y(y){ }12 };13 node operator-(node u,node v){return node(u.x-v.x,u.y-v.y);}14 node o... 阅读全文
posted @ 2013-10-31 00:36 Yours1103 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 计算几何边的旋转、直线相交的应用代码: 1 #include 2 #include 3 using namespace std; 4 struct node 5 { 6 double x,y; 7 node(double x=0,double y=0):x(x),y(y){} 8 }a,b,c,d,e,f; 9 node operator-(node u,node v){return node(u.x-v.x,u.y-v.y);}10 node operator+(node u,node v){return node(u.x+v.x,u.y+v.y);}11 node o... 阅读全文
posted @ 2013-10-30 21:09 Yours1103 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 计算几何;直线交点; 1 #include 2 using namespace std; 3 4 struct node 5 { 6 double x,y; 7 node(double x=0,double y=0):x(x),y(y){ } 8 }a,b,c,d,e,f,p,q,r; 9 node operator-(node u,node v){return node(u.x-v.x,u.y-v.y);}10 node operator+(node u,node v){return node(u.x+v.x,u.y+v.y);}11 node operator*(node... 阅读全文
posted @ 2013-10-30 16:57 Yours1103 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 简单的AC自动机; 1 #include 2 #include 3 #include 4 #define maxn 150005 5 using namespace std; 6 7 struct node 8 { 9 int cnt; 10 int id; 11 node *a[26],*tail; 12 }no[maxn]; 13 int nonocount; 14 node *newnode() 15 { 16 node *p=no+nonocount++; 17 p->cnt=0; 18 p->id=-1; 19 ... 阅读全文
posted @ 2013-10-30 15:46 Yours1103 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 简单KMP: 1 #include 2 #include 3 #define maxn 1000009 4 using namespace std; 5 6 char s[maxn]; 7 int next[maxn],n; 8 9 void getnext()10 {11 int j=-1,i=0;12 next[0]=-1;13 while(i0&&i%(i-next[i])==0)35 printf("%d %d\n",i,i/(i-next[i]));36 puts("");37 }38 ret... 阅读全文
posted @ 2013-10-30 14:52 Yours1103 阅读(141) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 26 下一页