/ 科创班 /

记录详情

Compile Error

/in/foo.c:1:25: fatal error: bits/stdc++.h: No such file or directory
 #include <bits/stdc++.h>
                         ^
compilation terminated.

代码

#include <bits/stdc++.h>
#define maxn 10001

using namespace std;

int c[maxn];
int f[maxn];

struct node
{
	int x;
	int y;
	int data;
	int m;
	node()
	{
		x = y = data = m = 0;
	}
};
node a[maxn];

bool cmp(const node &a,const node &b)
{
	return  a.data < b.data;
}

int ifind(int x)
{
	if(f[x] != x)
	{
		return f[x] = ifind(f[x]);
	}
	return f[x];
}
using namespace std;

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int minn = 0x3f;
	for(int i = 1;i <= n;i++)
	{
		cin >> c[i];
		if(c[i] < minn)
		{
			minn = c[i];
		}
	}
	for(int i = 1;i < maxn;i++)
	{
		f[i] = i;
	}
	for(int i = 1;i <= m;i++)
	{
		cin >> a[i].x >> a[i].y >> a[i].data;
	}
	sort(a + 1,a + 1 + m,cmp);
	int ans = 0;
	int t = 0;
	int w[maxn];
	for(int i = 1;i <= m;i++)
	{
		int r1 = ifind(a[i].x);
		int r2 = ifind(a[i].y);
		w[i] = 2 * a[i].data + c[a[i].x] + c[a[i].y];
		if(r1 != r2)
		{
			f[r1] = r2;
			ans += w[i];
			t++;
		}
		if(t == n - 1)
		{
			break;
		}
	}
	cout << ans + minn;
	cout << endl;
	return 0;
}

信息

递交者
类型
递交
题目
安慰奶牛
题目数据
下载
语言
C
递交时间
2022-01-17 07:57:51
评测时间
2022-01-17 07:57:51
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes