Codeforces Beta Round 62
D
Half-decay tree
Codeforces
2500
原题
← CE →
翻译中…

Recently Petya has become keen on physics. Anna V., his teacher noticed Petya's interest and gave him a fascinating physical puzzle — a half-decay tree.

翻译中…

A half-decay tree is a complete binary tree with the height $*h*$. The height of a tree is the length of the path (in edges) from the root to a leaf in the tree. While studying the tree Petya can add electrons to vertices or induce random decay with synchrophasotron. Random decay is a process during which the edges of some path from the root to the random leaf of the tree are deleted. All the leaves are equiprobable. As the half-decay tree is the school property, Petya will return back the deleted edges into the tree after each decay.

翻译中…

After being desintegrated, the tree decomposes into connected components. Charge of each component is the total quantity of electrons placed in vertices of the component. Potential of desintegerated tree is the maximum from the charges of its connected components. Each time before inducing random decay Petya is curious about the mathematical expectation of potential of the tree after being desintegrated.

翻译中…

Input

翻译中…

First line will contain two integers $*h*$ and $*q*$ ($1 ≤ *h* ≤ 30, 1 ≤ *q* ≤ 10^{5}$). Next $*q*$ lines will contain a query of one of two types:

翻译中…
  • add $*v*$ $*e*$Petya adds $*e*$ electrons to vertex number $*v*$ ($1 ≤ *v* ≤ 2^{*h* + 1} - 1, 0 ≤ *e* ≤ 10^{4}$). $*v*$ and $*e*$ are integers.The vertices of the tree are numbered in the following way: the root is numbered with 1, the children of the vertex with number $*x*$ are numbered with $2*x*$ and $2*x* + 1$.
  • decayPetya induces tree decay.
翻译中…

Output

翻译中…

For each query decay solution you should output the mathematical expectation of potential of the tree after being desintegrated. The absolute or relative error in the answer should not exceed $10^{ - 4}$.

翻译中…

样例

Input #1
1 4
add 1 3
add 2 10
add 3 11
decay
Output #1
13.50000000
InputCopy OutputCopy
题目信息
题号
68D
时间限制
3 s
内存限制
256 MB
标签
数据结构
分治
动态规划
数学
概率论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。