09 2013 档案

摘要:【题意】:给出n个点的坐标 求这里面两点距离的平方最大的 输出其值#include#include#includeusing namespace std;struct point{int x;int y;};point p[60000],ch[60000],v,w;int m,n;int cmp(point a,point b){ if(a.x!=b.x) return a.x1&&cross(ch[m-1],ch[m-2],p[i])1 再判断后面的 { m--; } ch[m].x=... 阅读全文
posted @ 2013-09-30 19:59 galaxy77 阅读(187) 评论(0) 推荐(0)
摘要:#include #include #include #includeusing namespace std;int main(){ map mapStudent; mapStudent["student_one\0"]=1; mapStudent["student_two\0"]=2; mapStudent["student_three\0"]=3; if(mapStudent.find("student_four\0")==mapStudent.end()) mapStudent["student_f 阅读全文
posted @ 2013-09-27 11:03 galaxy77 阅读(166) 评论(0) 推荐(0)
摘要:给出圆心坐标和半径 还有线段的两个端点判断线段是全在圆内还是部分在圆内 或是 全在圆外#include#include#includeusing namespace std;struct point{double x;double y;};double length(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); }double dot(point a,point b){ return a.x*b.x+a.y*b.y;}double cross(point a,point b){ ... 阅读全文
posted @ 2013-09-26 21:35 galaxy77 阅读(417) 评论(0) 推荐(0)
摘要:poj 3207 Ikki's Story IV - Panda's Trick http://poj.org/problem?id=3207【题意】在一个环上有n个点 m组连线(连接这两个点的线可以在环内也可以在环外) 判断这些线是否可以互不相交(第一次写的 2-sat 还蛮顺利的 1a 哈~~) 1 #include 2 #include 3 #include 4 using namespace std; 5 6 vector g[1002]; 7 8 int vis[1002],u[1002],v[1002],c,w[1002],m,n; 9 int max(int... 阅读全文
posted @ 2013-09-23 21:20 galaxy77 阅读(242) 评论(0) 推荐(0)
摘要:最优比率生成树poj 2728 Desert King http://poj.org/problem?id=2728题意:有n个村庄,村庄在不同坐标和海拔,现在要对所有村庄供水,只要两个村庄之间有一条路即可,建造水管距离为坐标之间的欧几里德距离(好象是叫欧几里德距离吧),费用为海拔之差现在要求方案使得费用与距离的比值最小 http://www.cppblog.com/jh818012/articles/167743.html 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define INF 1000 阅读全文
posted @ 2013-09-18 20:54 galaxy77 阅读(203) 评论(0) 推荐(0)
摘要:今天数值分析课上讲了一个很有用的求多项式的方法,给n个点的坐标就可以求出这个函数的多项式来 如给两个点就可以求出这条直线的多项式 给三个点就可以求出这条抛物线(或直线)的多项式最简单的一个应用就是 已知两点的坐标 求这条直线的函数接下来把值带进去就行了不得不说这个还真的是 很难画诶。。。 = = 阅读全文
posted @ 2013-09-13 22:38 galaxy77 阅读(219) 评论(0) 推荐(0)
摘要:poj 1679 The Unique MST http://poj.org/problem?id=1679求最小生成树是否唯一把构成最小生成树的边一条条的删#include#include#include#include#includeusing namespace std;struct E{ friend bool operator n2.w; } int u;int v;int w;}edge[10000];vector g[102];priority_queue q;int n,f[102],vis[102];int find(int a){ return ... 阅读全文
posted @ 2013-09-10 20:44 galaxy77 阅读(203) 评论(0) 推荐(0)
摘要:poj 1094 Sorting It All Out http://poj.org/problem?id=1094【题意】:给出n个点 m对大小关系 求输入第几对关系的时候 可以把整个图n个点的大小关系确定 或出现环 一旦发现出现了环或确定下了大小关系后面的都不用管了 做法是: 每进去一条边就判断一次 一发现都上述两种情况就可以输出了 1 #include 2 #include 3 using namespace std; 4 int g[100][100],ss[100],n,m,degree[100],uu[1000],vv[1000],temp[100]; 5 6 7 int so.. 阅读全文
posted @ 2013-09-10 20:32 galaxy77 阅读(208) 评论(0) 推荐(0)
摘要:待续。。。 阅读全文
posted @ 2013-09-10 16:30 galaxy77 阅读(175) 评论(0) 推荐(0)
摘要:Trajan算法求出图中所有的scc :考虑强连通分量c 设其中第一个被发现的点是x 则c中其他店都是x的后代 我们希望在x访问完成后立即输出c这样就可以在一节课dfs数中区分出所有的 scc了。因此问题的 关键是判断一个点是不是一个scc中最早发现的点。联系求割点算法, 若是一个点u,low[u]==pre[u] 即一个点不能连到比他更早的祖先节点 而最多只能连到他自己 就说明他是这个scc中最早发现的点算法模板:#include#include#include#includeusing namespace std;int pre[5002],low[5002],lt_num,c,scc_n 阅读全文
posted @ 2013-09-10 15:56 galaxy77 阅读(539) 评论(0) 推荐(0)
摘要:给出一个完全二分图 每条边有一个权值 要求求出权值和最大的完美匹配代码:#include#include#includeusing namespace std;int c1,c2,w[1002][1002],lx[102],ly[102],s[102],t[102],link[102];void update(){ int i,j; int a=1 2 #include 3 #include 4 5 using namespace std; 6 struct node{int x;int y;} man[102],house[102]; 7 char ss[102][... 阅读全文
posted @ 2013-09-09 22:06 galaxy77 阅读(243) 评论(0) 推荐(0)
摘要:ok 阅读全文
posted @ 2013-09-07 20:07 galaxy77 阅读(128) 评论(0) 推荐(0)
摘要:先贴个ISAP的算法模板 从源点s到汇点t 结点共有n个算法部分基本都是这模板 主要看思路和建图 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 struct E{int f... 阅读全文
posted @ 2013-09-06 21:39 galaxy77 阅读(309) 评论(0) 推荐(0)