HBC210239ANationalPandemic题解

一天到晚红烧的鱼 算法基础篇 73 0
想要检验自己的编程水平?来试试全网最全C++题库,让您在挑战中不断进步。
Nowadays, the Kingdom of Dreamgrid is suffering from a national pandemic. Fortunately, president Baobao is working effectively with the Center for Disease Control (CDC) and they are trying their bes

Nowadays, the Kingdom of Dreamgrid is suffering from a national pandemic. Fortunately, president Baobao is working effectively with the Center for Disease Control (CDC) and they are trying their best to make everything under control. As the chief of CDC, you are required to update the situation simultaneously and answer queries from president Baobao himself and reporters from News agencies in the world. Specifically, let's consider the country as a map of n nodes, denoting cities. Due to the severe pandemic, most roads and highways are closed except n-1 roads, which keep the country connected. We also define F(x) for each city x as the severity of the local disease situation. Now you need to deal with three kinds of events/queries: Another outbreak happens in city x with the severity value of w. For each city y, F(y) will be increased by w−dist(x,y)w-mathit{dist}(x,y)w−dist(x,y), where dist(x,y)mathit{dist}(x,y)dist(x,y) is the number of edges on the path from x to y. Update F(x) of city x to min⁡(F(x),0)min(F(x),0)min(F(x),0), which means the situation in city x has been improved with the effort of the government and medical faculties. Query for the severity value F(x) of city x. Every city's severity value F is 0 initially. Also, F(x) can be negative in some moment and we don't have to adjust it.

HBC210239ANationalPandemic题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
成为编程大师,不再是梦想!全网最全C++题库,助您开启编程新篇章。

标签: HBC210239ANationalPandemic题解