> 急的我都翻了遍题解,这好像跟std没区别了
所以到底有没有区别?
by Nero_Claudius @ 2018-07-13 15:06:55
~~没有区别就不会wa了~~
by PBCWZCC @ 2018-07-13 15:18:20
$long long$了解一下?
by 狸狸养的敏敏 @ 2018-07-13 15:19:25
~~还有您为何要手打Std里有的东西QwQ~~
by 狸狸养的敏敏 @ 2018-07-13 15:20:03
$\mathrm{long\space long}$ 没用 || @[P指向NULL](/space/show?uid=58399)
by PBCWZCC @ 2018-07-13 15:30:36
您能不能将最后的数据私发我,我帮您调调
by 狸狸养的敏敏 @ 2018-07-13 15:31:42
@[P指向NULL](/space/show?uid=58399) 算了我去手动搬数据吧 @[PBCWZCC](/space/show?uid=28004)
by 狸狸养的敏敏 @ 2018-07-13 15:32:18
~~数据下载失败~~
by PBCWZCC @ 2018-07-13 15:33:55
谢谢啦 || @[P指向NULL](/space/show?uid=58399)
by PBCWZCC @ 2018-07-13 15:34:13
@[PBCWZCC](/space/show?uid=28004) 小伙子我调好了,自己看看错哪了。QwQ,5000个点200000条边就开5000,200000的数组,真讲究,你不知道C++下标是从0开始的吗QwQ,(´・ω・`) int a[200000]其实下标是a[0]~a[199999]
```cpp
#include<algorithm>
#include<cstdio>
using namespace std;
template <class T> inline void read(T &X)
{
X = 0;
register char symbol(0),ch(getchar());
while(ch<'0'||'9'<ch)
{
ch=='-' ? symbol = 1 : 1 , ch = getchar();
}
while('0'<=ch&&ch<='9')
{
X = (X<<3) + (X<<1) + (ch^48) , ch = getchar();
}
symbol ? X = -X : 1;
}
template <class T> inline T max_(T X,T Y)
{
return X<Y?Y:X;
}
template <class T> inline T min_(T X,T Y)
{
return X<Y?X:Y;
}
template <class T> inline T abs_(T X)
{
return X<0?-X:X;
}
#define MAXM 200001
#define MAXN 5001
struct edge{
int u,v,w;
bool operator<(const edge ee)const;
void addE(const int,const int,const int);
}E[MAXM|1];
int cnt,ans;
inline bool edge::operator<(const edge ee)const
{
return w < ee.w;
}
inline void edge::addE(const int u,const int v,const int w)
{
this->u = u , this->v = v , this->w = w ;
}
//inline bool cmp_(edge ea,edge eb)
//{
// return ea.w < eb.w;
//}
int F[MAXN];
//inline int findf(int Fa[], int x)
//{
// return x==Fa[x] ? x : Fa[x]=findf(Fa,Fa[x]);
//}
inline int findf(int x)
{
return x == F[x] ? x : F[x] = findf(F[x]);
}
int n,m;
int main()
{
register int u,v,w;
read(n),read(m);
for(register int i(1);i<=n;++i)
{
F[i] = i;
}
for(register int i(1);i<=m;++i)
{
read(u) , read(v) , read(w);
E[i].addE(u,v,w);
}
sort(E+1,E+m+1);
register int fu,fv;
for(register int i(1);i<=m;++i)
{
fu = findf(E[i].u) , fv = findf(E[i].v) ;
if(fu!=fv)
{
++cnt;
F[fu] = fv;
ans += E[i].w;
if(cnt == n-1) break;
}
}
printf("%d",ans);
return 0;
}
```
by 狸狸养的敏敏 @ 2018-07-13 15:42:36