码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces 343D-线段树, DFS序

时间:2018-02-13 00:11:31      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:这一   ice   translate   input   mpi   children   this   post   follow   

Description

Translated by @Nishikino_Maki from Luogu
行吧是我翻的

  • Mad scientist Mike has constructed a rooted tree, which consists of n n vertices. Each vertex is a reservoir which can be either empty or filled with water.
  • The vertices of the tree are numbered from 1 to n n with the root at vertex 1. For each vertex, the reservoirs of its children are located below the reservoir of this vertex, and the vertex is connected with each of the children by a pipe through which water can flow downwards.
  • Mike wants to do the following operations with the tree:
  1. Fill vertex v with water. Then v and all its children are filled with water.
  2. Empty vertex v . Then v and all its ancestors are emptied.
  3. Determine whether vertex v is filled with water at the moment.
  • Initially all vertices of the tree are empty.Mike has already compiled a full list of operations that he wants to perform in order. Before experimenting with the tree Mike decided to run the list through a simulation. Help Mike determine what results will he get after performing all the operations.

  • 疯狂科学家Mike培养了一颗有根树,由n个节点组成。每个节点是一个要么装满水要么为空的贮水容器. 树的节点用1~n编号,其中根节点为1.对于每个节点的容器,其子节点的容器均在这一容器下方,并且每个节点都由一根可以向下流水的管道与其子节点连接. Mike想要对这棵树做以下操作:

  1. 将节点v注满水. 这样v和其子节点都会充满水.
  2. 将节点v置空. 这样v及其祖先节点(从v到根节点的路径)都会被置空.
  3. 查询当前节点v是否充满水.
  • 初始时,所有节点都为空. Mike已经制定好了他的操作顺序. 在对树进行实验前,他决定先模拟一下操作. 请你帮助Mike得出他操作后的结果.

Input&Output

Codeforces 343D-线段树, DFS序

标签:这一   ice   translate   input   mpi   children   this   post   follow   

原文地址:https://www.cnblogs.com/nishikino-curtis/p/8445856.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!