2013年8月3日
摘要: 模板题刚学的最小生成树 有点小兴奋#include #include #include #include using std::sort;struct dat{ int nx; int ny; double nl; bool operator<(const dat p) const { return nl<p.nl; }}a[250010];int n,s,b;double point[510][2];int p[510];int find(int x){return p[x]==x?x : p[x]=find(p[x]);}int main(... 阅读全文
posted @ 2013-08-03 20:42 风流monkey 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 二分查找最小值#include #include #include #define N 100010using std:: sort;int a[N];int n,m;int solve(int x){ int cas=0; int nx=1; for(int i=2; i=x) { cas++; nx=i; } } return cas+1;}int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d ... 阅读全文
posted @ 2013-08-03 20:10 风流monkey 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 借鉴别人的思路http://blog.sina.com.cn/s/blog_76102a690100q0gr.html#include #include using std::sort;int n,a[1010],b[1010];int main(){ while(scanf("%d",&n)==1 && n) { for(int i=0; ib[b2]) { sum+=(a2-a1+1); break; } else if(a[a2]>b[b... 阅读全文
posted @ 2013-08-03 15:09 风流monkey 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 最小生成树 自己太死板了!老是RE 最后才发现数组开小了!将已连接的点的权值赋值为零就好了#include #include #include #include #include #define N 150000#define M 755using std::sort;struct dat{ int nx; int ny; double nl; bool operator <(const dat p)const { return nl<p.nl; }} a[600000];double point[M][2];bool vis[M][M];i... 阅读全文
posted @ 2013-08-03 12:46 风流monkey 阅读(105) 评论(0) 推荐(0) 编辑