树
日常懵
菜鸟一只
展开
-
洛谷P2872
洛谷P2872 [USACO07DEC]Building Roads S (一个最小生成树,小菜鸟卡了一个半小时) 题目链接 (关于最小生成树菜鸟的另一篇博客里有) 代码 #include <bits/stdc++.h> using namespace std; const int N = 1010 , M = N * N * 2 ; int n , m ; int find_all[N]; struct node //存储的坐标 { long long a, b; }all[N];原创 2021-04-13 21:03:38 · 110 阅读 · 0 评论 -
树的直径
树的直径 思路 从一个点开始,找距离这个点最远的点x 从x开始搜索,找距离x点最远的点 y x和y距离就是数直径的最大值 题目 Cow Marathon 代码 : #include <iostream> #include <queue> #include <cstring> #include <algorithm> #include <cstdio> //poj不支持万能头 using namespace std; const int N=原创 2021-04-10 15:23:15 · 55 阅读 · 0 评论