There are nnn cities and they are connected by n1n-1n1 railways. In other words, the city and the railway form a tree. There is a strange rule about the charging method in this place. The travel fare required for a passenger to travel ttt kilometers ist2t^2t2. Please note that passengers cannot divide a journey into several shorter journeys in order to achieve the purpose of reducing tolls. There is an event to be held in this place. There are cic_icicontestants in the iii city. You have to choose a city to hold this event to minimize the sum of travel expenses for all contestants.
There are nnn cities and they are connected by n−1n-1n−1 railways. In other words, the city and the railway form a tree. There is a strange rule about the charging method in this place. The travel fare required for a passenger to travel ttt kilometers is t2t^2t2. Please note that passengers cannot divide a journey into several shorter journeys in order to achieve the purpose of reducing tolls. There is an event to be held in this place. There are cic_ici contestants in the iii city. You have to choose a city to hold this event to minimize the sum of travel expenses for all contestants.
标签: HBC229646Palindrome 单调队列单调栈 后缀数组(SA) Manacher 字符串Problem F. fare题解