NIRVANA


  • HOME

  • TAGS

  • ARCHIVES

  • ABOUT

  • SITEMAP

  • SEARCH

BZOJ4872【SHOI2017】分手是祝愿 <概率DP>

发表于 2018-10-01
字数统计: 818 | 阅读时长 ≈ 4

Problem

【SHOI2017】分手是祝愿


Description

Zeit und Raum trennen dich und mich.
时空将你我分开。 君 在玩一个游戏,这个游戏由 个灯和 个开关组成,给定这 个灯的初始状态,下标为从 到 的正整数。每个灯有两个状态亮和灭,我们用 来表示这个灯是亮的,用 表示这个灯是灭的,游戏的目标是使所有灯都灭掉。但是当操作第 个开关时,所有编号为 的约数(包括 和 )的灯的状态都会被改变,即从亮变成灭,或者是从灭变成亮。 君 发现这个游戏很难,于是想到了这样的一个策略,每次等概率随机操作一个开关,直到所有灯都灭掉。这个策略需要的操作次数很多, 君 想到这样的一个优化。如果当前局面,可以通过操作小于等于 个开关使所有灯都灭掉,那么他将不再随机,直接选择操作次数最小的操作方法(这个策略显然小于等于 步)操作这些开关。 君 想知道按照这个策略(也就是先随机操作,最后小于等于 步,使用操作次数最小的操作方法)的操作次数的期望。这个期望可能很大,但是 君 发现这个期望乘以 一定是整数,所以他只需要知道这个整数对 取模之后的结果。

Input

第一行两个整数 , 。
接下来一行 个整数,每个整数是 或者 ,其中第 个整数表示第 个灯的初始情况。
,

Output

一行,为操作次数的期望乘以 对 取模之后的结果。

阅读全文 »

CF264E Roadside Trees <线段树>

发表于 2018-10-01
字数统计: 1,443 | 阅读时长 ≈ 7

Problem

Roadside Trees


Description

Squirrel Liss loves nuts. Liss asks you to plant some nut trees.
There are positions (numbered 1 to from west to east) to plant a tree along a street. Trees grow one meter per month. At the beginning of each month you should process one query. The query is one of the following types:

  • Plant a tree of height at position .
  • Cut down the existent (not cut) tree from the west (where is 1-indexed). When we cut the tree it drops down and takes all the available place at the position where it has stood. So no tree can be planted at this position anymore.

After processing each query, you should print the length of the longest increasing subsequence. A subset of existent trees is called an increasing subsequence if the height of the trees in the set is strictly increasing from west to east (for example, the westmost tree in the set must be the shortest in the set). The length of the increasing subsequence is the number of trees in it.
Note that Liss don’t like the trees with the same heights, so it is guaranteed that at any time no two trees have the exactly same heights.

Input

The first line contains two integers: and – the number of positions and the number of queries.
Next lines contains the information of queries by following formats:

  • If the query is type 1, the line contains three integers: 1, , and , where is the position of the new tree and is the initial height of the new tree.
  • If the query is type 2, the line contains two integers: 2 and , where the is the index of the tree we want to cut.
    The input is guaranteed to be correct, i.e.,
  • For type 1 queries, will be pairwise distinct.
  • For type 2 queries, will be less than or equal to the current number of trees.
  • At any time no two trees have the exactly same heights.

In each line integers are separated by single spaces.

Output

Print integers – the length of the longest increasing subsequence after each query. Separate the numbers by whitespaces.

阅读全文 »

BZOJ3566【SHOI2014】概率充电器 <概率DP+树形DP>

发表于 2018-09-27
字数统计: 897 | 阅读时长 ≈ 4

Problem

【SHOI2014】概率充电器


Description

著名的电子产品品牌 刚刚发布了引领世界潮流的下一代电子产品——概率充电器:
“采用全新纳米级加工技术,实现元件与导线能否通电完全由真随机数决定! 概率充电器,您生活不可或缺的必需品!能充上电吗?现在就试试看吧!”
概率充电器由 条导线连通了 个充电元件。进行充电时,每条导线是否可以导电以概率决定,每一个充电元件自身是否直接进行充电也由概率决定。
随后电能可以从直接充电的元件经过通电的导线使得其他充电元件进行间接充电。
作为 公司的忠实客户,你无法抑制自己购买 产品的冲动。在排了一个星期的长队之后终于入手了最新型号的 概率充电器。
你迫不及待地将 概率充电器插入电源——这时你突然想知道,进入充电状态的元件个数的期望是多少呢?

Input

第一行一个整数 表示概率充电器的充电元件个数,充电元件由 编号。
之后的 行每行三个整数 ,描述了一根导线连接了编号为 和 的充电元件,通电概率为 。
第 行 个整数 。表示 号元件直接充电的概率为 。

Output

输出一行一个实数,为进入充电状态的元件个数的期望,四舍五入到六位小数。

阅读全文 »

BZOJ5197【CERC2017】Gambling Guide <概率DP+Dijkstra>

发表于 2018-09-27
字数统计: 959 | 阅读时长 ≈ 4

Problem

【CERC2017】Gambling Guide



Description

给定一张 个点, 条双向边的无向图。
你要从 号点走到 号点。当你位于 点时,你需要花 元钱,等概率随机地买到与 相邻的一个点的票,只有通过票才能走到其它点。
每当完成一次交易时,你可以选择直接使用那张票,也可以选择扔掉那张票然后再花 元钱随机买另一张票。注意你可以无限次扔票。
请使用最佳的策略,使得期望花的钱数最少。

Input

第一行包含两个正整数 ,表示点数和边数。
接下来 行,每行两个正整数 ,表示一条双向边。
输入数据保证无重边、无自环,且 号点一定可以走到 号点。

Output

输出一行一个实数,即最少的期望花费,当绝对或者相对误差不超过 时视为正确。

阅读全文 »

BZOJ1415【NOI2005】聪聪和可可 <概率DP+最短路>

发表于 2018-09-27
字数统计: 777 | 阅读时长 ≈ 4

Problem

【NOI2005】聪聪和可可


Description



Input

第一行为两个整数 和 ,以空格分隔,分别表示森林中的景点数和连接相邻景点的路的条数。
第二行包含两个整数 和 ,以空格分隔,分别表示初始时聪聪和可可所在的景点的编号。
接下来 行,每行两个整数,第 行的两个整数 和 表示景点 和景点 之间有一条无向边。
输入保证任何两个景点之间不会有多于一条路直接相连,且聪聪和可可之间必有路直接或间接的相连。

Output

输出一个实数,四舍五入保留三位小数,表示平均多少个时间单位后聪聪会把可可吃掉。

阅读全文 »

BZOJ2201 彩色圆环 <概率DP>

发表于 2018-09-26
字数统计: 500 | 阅读时长 ≈ 2

Problem

彩色圆环


Description



Input

仅有一行,该行给出依次两个正整数 ,分别表示宝石的个数和宝石在变化时可能变成的颜色种类数。

Output

应仅有一行,该行给出一个实数 ,表示圆环的“美观程度”的期望值。

阅读全文 »

BZOJ2688 Green Hackenbush <概率DP+博弈论>

发表于 2018-09-26
字数统计: 670 | 阅读时长 ≈ 3

Problem

Green Hackenbush


Description

有一个古老的游戏叫做 ,游戏是这样进行的:两个人轮流在一棵树上删边,每次删边后不与根联通的子树直接被忽略,不能删边的游戏者输。 和 也在玩这个游戏,不过他们面对的是 棵树,第 棵树是含有 个节点的二叉树。先手的 想知道自己有多大的概率获胜(假设我们的 和 同学都是无限聪明的)。

Input

第一行一个数 。
接下来每行一个数 。

Output

一个保留 位小数的实数 。

阅读全文 »

ARC072E Alice in linear land < DP >

发表于 2018-09-25
字数统计: 878 | 阅读时长 ≈ 5

Problem

Alice in linear land


Statement

Alice lives on a line. Today, she will travel to some place in a mysterious vehicle. Initially, the distance between Alice and her destination is . When she input a number to the vehicle, it will travel in the direction of the destination by a distance of if this move would shorten the distance between the vehicle and the destination, and it will stay at its position otherwise. Note that the vehicle may go past the destination when the distance between the vehicle and the destination is less than .
Alice made a list of numbers. The number in this list is . She will insert these numbers to the vehicle one by one.
However, a mischievous witch appeared. She is thinking of rewriting one number in the list so that Alice will not reach the destination after moves.
She has plans to do this, as follows:
Rewrite only the number in the list with some integer so that Alice will not reach the destination.
Write a program to determine whether each plan is feasible.

Constraints






and each are integers.

Input

Input is given from Standard Input in the following format:



Output

Print lines. The line should contain YES if the plan is feasible, and NO otherwise.

阅读全文 »

AGC021E Ball Eat Chameleons <组合数学>

发表于 2018-09-23
字数统计: 1,191 | 阅读时长 ≈ 6

Problem

Ball Eat Chameleons


Statement

In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps Snuke Chameleons in a cage.
A Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following rules:

  • A Snuke Chameleon that is blue will change its color to red when the number of red balls it has eaten becomes strictly larger than the number of blue balls it has eaten.
  • A Snuke Chameleon that is red will change its color to blue when the number of blue balls it has eaten becomes strictly larger than the number of red balls it has eaten.

Initially, every Snuke Chameleon had not eaten anything. Ringo fed them by repeating the following process K times:

  • Grab either a red ball or a blue ball.
  • Throw that ball into the cage. Then, one of the chameleons eats it.

After Ringo threw in balls, all the chameleons were red. We are interested in the possible ways Ringo could have thrown in balls. How many such ways are there? Find the count modulo . Here, two ways to throw in balls are considered different when there exists such that the color of the ball that are thrown in the throw is different.

Constraints


and are integers.

Input

Input is given from Standard Input in the following format:

Output

Print the possible ways Ringo could have thrown in balls, modulo .

阅读全文 »

CF995F Cowmpany Cowmpensation < 树形DP+多项式插值 >

发表于 2018-09-22
字数统计: 1,004 | 阅读时长 ≈ 5

Problem

Cowmpany Cowmpensation


Description

Allen, having graduated from the MOO Institute of Techcowlogy (MIT), has started a startup! Allen is the president of his startup. He also hires other employees, each of which is assigned a direct superior. If is a superior of and is a superior of then also is a superior of . Additionally, there are no and such that is the superior of and is the superior of . Allen himself has no superior. Allen is employee number , and the others are employee numbers through .
Finally, Allen must assign salaries to each employee in the company including himself. Due to budget constraints, each employee’s salary is an integer between and . Additionally, no employee can make strictly more than his superior.
Help Allen find the number of ways to assign salaries. As this number may be large, output it modulo .

Input

The first line of the input contains two integers and ( , ).
The remaining lines each contain a single positive integer, where the line contains the integer ( ). denotes the direct superior of employee .

Output

Output a single integer: the number of ways to assign salaries modulo .

阅读全文 »
123…27
Azrael_Death

Azrael_Death

Veni, Vidi, Vici

270 日志
153 标签
RSS
GitHub ZhiHu
友链
  • OwenOwl
  • Joker
  • Aziint
  • DXY
  • Demon_Rieman
  • myjs999
  • wsyzh
  • YJQ
  • Candy
  • ZigZag
  • BYVoid
  • cxjyxx_me
  • ShuiZiLong
  • KuangBin
  • Crazy_Cloud
  • SkyWalkert
  • RuanXingZhi
  • Riteme
© 2019 Azrael_Death | Site words total count: 256.2k
本站访客数:
|
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4
0%