https://www.luogu.org/problemnew/show/P1746 思路:用广搜从起点开始,遍历所有可达的点,再往下遍历直到到达终点,所以能保证得到的结果一定是最优解 #include<bits/stdc++.h> using namespace std; int n,sx,sy,ex,ey;//sx.sy为起始坐标,ex.ey为目的地坐标 ][]; ]={,,-,}; ]={,,,-};//四个方向 struct node{//结构体 int x,y,step;//ste…
To 洛谷.2982 慢下来Slowing down 题目描述 Every day each of Farmer John's N (1 <= N <= 100,000) cows conveniently numbered 1..N move from the barn to her private pasture. The pastures are organized as a tree, with the barn being on pasture 1. Exactly N-1 cow…