|
VIP犯了和楼上一样的错误! t,x,y读反了!!
题目 61 [HNOI 2004] 打鼹鼠
2016-02-26 16:35:37
|
|
不错
页面 59 [题目] 国家集训队论文题
2016-02-26 13:56:49
|
|
循环里cnt更新时是变成1还是变成0纠结了一会儿
|
|
#include<iostream>
#include<cstdio> #include<cstring> using namespace std; const int maxn=1000; struct Node{ int from,to,cost; }a[100001]; bool comp(const Node &a,const Node &b){ return a.cost<b.cost; } int n,m,root[1001]; void Kruskal(); int Findroot(int); int main(){ cin>>n>>m; for(int i=1;i<=m;i++){ int x,y,z;cin>>x>>y>>z; a[i].from=x;a[i].to=t;a[i].cost=z; } Kruskal(); return 0; } void Kruskal(){ int ans=0,cnt=0; for(int i=1;i<=n;i++){ root[i]=i; } sort(a+1,a+m+1,comp); for(int i=1;i<=m;i++){ int x=a[i].from,y=a[i].to; int rx=Findroot(x),ry=Findroot(y); if(rx==ry) continue; else{ root[rx]=ry;cnt++; if(a[i].cost>ans) ans=a[i].cost; } if(cnt==n-1) break; } if } int Findroot(int x){ if(x!=root[x]){ root[x]=Findroot(root[x]); } return root[x]; }
题目 1109 [福州培训2010] 修复公路
2016-02-26 11:11:20
|
|
感谢楼上评论的提示+1....
做这题不要偷懒,老老实实O(n^2)枚举每种方案的买入/卖出价差值和这种方案的获利 |
|
读错题了。。。一开始还以为要像298.食物链 一样对每句输入都进行判断,调了半天发现这题是一组数据一个输出。
|
|
求区间长度居然用左减右,好傻啊,手写二路归并居然花了将近两节课,我选择死亡
![]() |
|
只会O(n^2)DP的蒟蒻表示看不懂榜上一堆神奇的O(n)算法.....
|
|
|
|
没看到评论提醒,a[(x+y)>>1]忘清零+1。。。
|
|
[size=32]不要方,慢慢来[/size]
|
|
不自量力写了个30分的树状数组。。。
|
|
感人OAQ
页面 59 [题目] 国家集训队论文题
2016-02-26 09:31:41
|
|
你们搞的这个页面啊,excited!
页面 59 [题目] 国家集训队论文题
2016-02-26 09:31:28
|
|
%%%
页面 59 [题目] 国家集训队论文题
2016-02-26 09:24:11
|
|
SAM打错了竟然对了8个点...
|
|
到此一游~
题目 918 [東方S1] 东风谷早苗
2016-02-25 20:28:01
|
|
Kruskal 路过
|
|
Kruskal 又不是不能过。
|
|
已确认cogs可用c++11 o(^▽^)o
|