记录编号 |
205410 |
评测结果 |
AAAAAAAAAA |
题目名称 |
不平凡的引线 |
最终得分 |
100 |
用户昵称 |
前鬼后鬼的守护 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.353 s |
提交时间 |
2015-11-05 12:15:34 |
内存使用 |
3.46 MiB |
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<queue>
const int MAXV=100000,D=10;
inline int read(){
int x=0;char ch=getchar();while(ch<'0'||ch>'9')ch=getchar();
while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();return x;
}
int n,ans;
struct edge{
int y,v,next;
}e[(MAXV<<1)+D];
int head[MAXV+D],degree[MAXV+D],dis[MAXV+D];bool exped[MAXV+D];
struct node{
int x,dis;
node(int a,int b):x(a),dis(b){}
};
inline bool operator<(node a,node b){return a.dis>b.dis;}
std::priority_queue<node> pq;
inline int min(int a,int b){return a<b?a:b;}
inline int max(int a,int b){return a>b?a:b;}
int main(){
freopen("firelead.in","r",stdin);
freopen("firelead.out","w",stdout);
n=read()+1;
for(int i=1;i<n;i++){
int x=read(),y=read(),v=read()<<1;
int k1=i<<1,k2=k1|1;degree[x]++;degree[y]++;
e[k1].y=y,e[k1].v=v,e[k1].next=head[x],head[x]=k1;
e[k2].y=x,e[k2].v=v,e[k2].next=head[y],head[y]=k2;
}
memset(dis,50,sizeof dis);
for(int i=1;i<=n;i++)if(degree[i]==1)dis[i]=0,pq.push(node(i,0));
while(!pq.empty()){
node now=pq.top();pq.pop();int x=now.x;
if(now.dis>dis[x])continue;
for(int i=head[x];i;i=e[i].next){
int y=e[i].y,d=dis[x]+e[i].v;
if(d<dis[y]){
dis[y]=d;
pq.push(node(y,d));
}
}
}
for(int x=1;x<=n;x++)
for(int i=head[x];i;i=e[i].next){
int y=e[i].y,h=max(dis[x],dis[y]),l=min(dis[x],dis[y]),t;
if(h-l>e[i].v)t=l+e[i].v;
else t=(h+l+e[i].v)>>1;
if(t>ans)ans=t;
}
printf("%.1lf",ans*1.0/2);
return 0;
}