/ Randle /

记录详情

Time Exceeded

/in/foo.cc: In function 'int read()':
/in/foo.cc:14:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if(ch=='-') w=-1;ch=getchar();
   ^~
/in/foo.cc:14:20: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
   if(ch=='-') w=-1;ch=getchar();
                    ^~
# 状态 耗时 内存占用
#1 Time Exceeded ≥1007ms ≥4.352 MiB
#2 Time Exceeded ≥1003ms ≥4.25 MiB
#3 Time Exceeded ≥1005ms ≥4.344 MiB
#4 Time Exceeded ≥1001ms ≥2.5 MiB
#5 Time Exceeded ≥1006ms ≥4.254 MiB
#6 Time Exceeded ≥1004ms ≥4.332 MiB
#7 Time Exceeded ≥1003ms ≥4.332 MiB
#8 Time Exceeded ≥1005ms ≥4.344 MiB
#9 Time Exceeded ≥1003ms ≥4.371 MiB
#10 Time Exceeded ≥1001ms ≥4.359 MiB

代码

#include<cstdio>
using namespace std;
#define ll long long
struct yff
{
	int v,w,next;
}zyj[288888];
int f[288888],ji=0,dis[2888888];
inline int read()
{
	int w=1,s=0;char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		s=s*10+ch-48;ch=getchar();
	}
	return w*s;
}
inline void add(int u,int v,int w)
{
	zyj[++ji].v=v;
	zyj[ji].w=w;
	zyj[ji].next=f[u];
	f[u]=ji;
}
int max(int a,int b)
{
	return a>b?a:b;
}
void dfs(int x,int fa)
{
	for(int i=f[x];i>0;i=zyj[i].next)
	{
		int to=zyj[i].v;
		if(to==fa) continue;
		dfs(to,x);
		dis[x]=max(dis[to]+zyj[i].w,dis[x]);
	}
}
int n,m,ans,sum;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		int a=read(),b=read(),c=read();
		add(a,b,c);
		add(b,a,c);
		sum+=c;
	}
	dfs(1,-1);
	ans=sum*2-dis[1];
	printf("%d\n",ans);
	return 0;
}

信息

递交者
类型
递交
题目
游 T2
题目数据
下载
语言
C++
递交时间
2018-04-25 14:44:51
评测时间
2018-04-25 14:44:51
评测机
分数
0
总耗时
≥10042ms
峰值内存
≥4.371 MiB