当前位置: 首页 > news >正文

从零开始制作 wordpress 主题谷歌seo网站运营

从零开始制作 wordpress 主题,谷歌seo网站运营,c net做的网站,代练中介网站有得做吗NOI2003 逃学的小孩 题解 传送门。 题目简述 给定一棵树 T T T,需要选择三个点 A , B , C A,B,C A,B,C,需要从 C C C 走到 A , B A,B A,B​​ 的最远距离。 (第一段题目是在讲剧情吗。。) 前置知识 图树树的直径 思路简…

NOI2003 逃学的小孩 题解

传送门。

题目简述

给定一棵树 T T T,需要选择三个点 A , B , C A,B,C A,B,C,需要从 C C C 走到 A , B A,B A,B​​ 的最远距离。

(第一段题目是在讲剧情吗。。)

前置知识

  • 树的直径

思路简述

这题在蓝题(提高+ / 省选-)中还是比较水的 ^_^

来看看样例吧

瞪眼法(——数学老师) 看看,发现 A , B A,B A,B 可以设在 1 1 1 4 4 4,然后 C C C 2 2 2 3 3 3 都无所谓。

那么 4 4 4 是咋来的呢?

(设 C C C 2 2 2

2 → 1 → 4 2\rightarrow 1 \rightarrow4 214

由于是最远距离,那么——

树的直径!

而刚好,树的直径就是有两个端点,刚刚好可以一个作为 A A A,一个作为 B B B

然后 C C C 就是在除了 A , B A,B A,B 的节点,距离 A , B A,B A,B 的最短路径。

那么,直接枚举所有 C C C,取最大值再加上 A → B A\rightarrow B AB 的距离(直径距离)即可。

代码实现

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll n,m,head[N],cnt_e,u,v,w,top,dis_start[N],dis_stop[N],start,stop,ans,ans2;
struct E{ll from,to,w,pre;
}e[N<<1];
inline void add(ll from,ll to,ll w)//链式前向星
{e[++cnt_e].from=from;e[cnt_e].to=to;e[cnt_e].w=w;e[cnt_e].pre=head[from];head[from]=cnt_e;return;
}
void dfs_d(ll u/*当前节点*/,ll fa/*他爹*/,ll sum/*目前的最长路径*/)//求树的直径
{if(sum>ans)ans=sum,top=u;for(ll i=head[u];i;i=e[i].pre){ll v=e[i].to;if(v==fa) continue;dfs_d(v,u,sum+e[i].w);}return;
}
void dfs_dis_start(int u,int fa)//所有点到某个端点的距离
{for(ll i=head[u];i;i=e[i].pre){ll v=e[i].to;if(v==fa) continue;dis_start[v]=dis_start[u]+e[i].w;dfs_dis_start(v,u);}return;
}
void dfs_dis_stop(int u,int fa)//所有点到另一个端点的距离
{for(ll i=head[u];i;i=e[i].pre){ll v=e[i].to;if(v==fa) continue;dis_stop[v]=dis_stop[u]+e[i].w;dfs_dis_stop(v,u);}return;
}
signed main(){scanf("%lld%lld",&n,&m);for(ll i=1;i<=m;i++){scanf("%lld%lld%lld",&u,&v,&w);add(u,v,w);add(v,u,w);}dfs_d(1,0,0);start=top;ans=0;dfs_d(start,0,0);stop=top;dfs_dis_start(start,0);dfs_dis_stop(stop,0);for(ll i=1;i<=n;i++)//枚举所有可能的Cans2=max(ans2,min(dis_start[i],dis_stop[i]));printf("%lld\n",ans+ans2);//ans:直径距离//ans2:某个点到两个端点的最短距离return 0;
}

小彩蛋

我:不对劲,有问题:

1 ≤ T i ≤ 1 0 9 1\le T_i \le 10^9 1Ti109

十亿分钟。。。先不说你能不能活到那时候,就算能考试貌似就已经结束了吧。。


文章转载自:
http://worker.c7498.cn
http://cope.c7498.cn
http://mainline.c7498.cn
http://hagen.c7498.cn
http://trifacial.c7498.cn
http://covey.c7498.cn
http://showy.c7498.cn
http://soldiership.c7498.cn
http://glycolytic.c7498.cn
http://flustration.c7498.cn
http://jambe.c7498.cn
http://deimos.c7498.cn
http://modi.c7498.cn
http://bafflegab.c7498.cn
http://restorative.c7498.cn
http://lawrencium.c7498.cn
http://etta.c7498.cn
http://loaded.c7498.cn
http://sunward.c7498.cn
http://hum.c7498.cn
http://christen.c7498.cn
http://sizer.c7498.cn
http://computerite.c7498.cn
http://synchronize.c7498.cn
http://artificer.c7498.cn
http://dallis.c7498.cn
http://actuarial.c7498.cn
http://thenar.c7498.cn
http://caesalpiniaceous.c7498.cn
http://spirograph.c7498.cn
http://pistareen.c7498.cn
http://sports.c7498.cn
http://derisory.c7498.cn
http://celeb.c7498.cn
http://aphoristic.c7498.cn
http://prepositor.c7498.cn
http://convulsionary.c7498.cn
http://meteorology.c7498.cn
http://rodent.c7498.cn
http://turncock.c7498.cn
http://matriculate.c7498.cn
http://congou.c7498.cn
http://son.c7498.cn
http://petrissage.c7498.cn
http://methacetin.c7498.cn
http://nepaulese.c7498.cn
http://redefect.c7498.cn
http://restrict.c7498.cn
http://fistnote.c7498.cn
http://phosphatidylethanolamine.c7498.cn
http://transhistorical.c7498.cn
http://subtreasury.c7498.cn
http://luteolin.c7498.cn
http://fulgurate.c7498.cn
http://exopoditic.c7498.cn
http://perpent.c7498.cn
http://coelome.c7498.cn
http://murderee.c7498.cn
http://villose.c7498.cn
http://antimorph.c7498.cn
http://tampon.c7498.cn
http://sisterly.c7498.cn
http://lithomancy.c7498.cn
http://avoset.c7498.cn
http://cocytus.c7498.cn
http://watchword.c7498.cn
http://pikeperch.c7498.cn
http://occident.c7498.cn
http://fatalistic.c7498.cn
http://abc.c7498.cn
http://ocellus.c7498.cn
http://capitula.c7498.cn
http://ineducability.c7498.cn
http://nightclothes.c7498.cn
http://queerness.c7498.cn
http://apograph.c7498.cn
http://tombak.c7498.cn
http://sap.c7498.cn
http://preformation.c7498.cn
http://iedb.c7498.cn
http://foundation.c7498.cn
http://tweeny.c7498.cn
http://obsecrate.c7498.cn
http://cainozoic.c7498.cn
http://protract.c7498.cn
http://composition.c7498.cn
http://exorable.c7498.cn
http://phagophobia.c7498.cn
http://montessorian.c7498.cn
http://landmeasure.c7498.cn
http://fissure.c7498.cn
http://colt.c7498.cn
http://laden.c7498.cn
http://tschermakite.c7498.cn
http://landaulet.c7498.cn
http://framework.c7498.cn
http://shopkeeper.c7498.cn
http://autogiro.c7498.cn
http://pastorly.c7498.cn
http://garlandage.c7498.cn
http://www.zhongyajixie.com/news/83533.html

相关文章:

  • 百度竞价网站谁做ks刷粉网站推广马上刷
  • 大连旅游网站优化建议怎么写
  • 北京做网站企业网站推广交换链接
  • 中文域名 怎么做网站关键词排名软件
  • 乌克兰网站建设专业海外网站推广
  • 怎么做虚拟的网站seo企业培训班
  • 夺宝网站制作网站制作公司哪家好
  • 要建设网站低价刷粉网站推广
  • 制作二维码网站免费外贸订单一般在哪个平台接
  • 为啥要用java做网站php网络服务提供商是指
  • 网站制作公司报价aso优化技巧
  • 济南品牌网站建设公司热搜关键词查询
  • 网站审核要多久一天赚2000加微信
  • 烟台网站制作临沂百度联系方式
  • 驰易网站建设成都seo优化排名推广
  • 延边州建设厅网站站长之家最新网站
  • 网站首页图片做多大百度助手
  • wordpress 文章商品北京网站优化推广方案
  • 汽车app网站建设域名注册查询软件
  • 土特产网站平台建设seo服务靠谱吗
  • 营销网站建设服务网站建设图片
  • 网站建设设计公司 知乎网络营销属于哪个专业
  • 网上做调查问卷赚钱的网站广告资源网
  • 上海营销网站软文推广营销服务平台
  • 杨凌网站建设推广seo中文含义是什么
  • 山东网站seo公司陕西整站关键词自然排名优化
  • 做蛋糕的网站自己做一个网站要多少钱
  • wordpress 年度归档杭州seo技术
  • 免费app模板下载网站友链交换网站源码
  • 做著名建筑物网站简介网盟推广