HBC52170翻转卡片,动态规划Birthday Reminders题解

惰性的成熟 算法基础篇 49 0
全网最全C++题库,助您快速提升编程技能!题库丰富多样,涵盖各个领域,让您在练习中不断成长!
Tomori has N friends. Some of the friends actually remembered her birthday!i, he or she will remember Tomori's birthday at time ti and give her a birthday wish at that instant (or not remember her birthday at all if. Some of Tomori's friends are very considerate however, and decides to remind others about her birthday. Friend i will remind friend pi about Tomori's birthday after he or she has wished her. Formally, if Friend i gave Tomori a birthday wish at time t, then he or she will remind friend pi to give Tomori a birthday wish at time t+1 (and friend pi will give her a birthday wish at time t+1 and remind friend. =i is possible, which means that the friend will not remind anyone about Tomori's birthday after sending their wish.The day is over and at the end of the day, Tomori receives the wish from Friend i at time. }, how many possible different days she could have experienced. Two permutations p, q correspond to different days if at some point of time, the number of friends who wished Tomori was different.

Today is Tomori's birthday! Usually, people get many birthday wishes on social media, but Tomori has decided to hide her birthday on social media, and thus does not expect many (if any) wishes from her friends.  Tomori has N friends. Some of the friends actually remembered her birthday! For each friend i i, he or she will remember Tomori's birthday at time ti and give her a birthday wish at that instant (or not remember her birthday at all if t_i = -1 t i ​ =−1). Some of Tomori's friends are very considerate however, and decides to remind others about her birthday. Friend i will remind friend pi about Tomori's birthday after he or she has wished her. Formally, if Friend i gave Tomori a birthday wish at time t, then he or she will remind friend pi to give Tomori a birthday wish at time t+1 (and friend pi will give her a birthday wish at time t+1 and remind friend  p_{p_{i}} p p i ​ ​ at time t+2 and so on, assuming that they have not already gave her a birthday wish). The sequence pi forms a permutation, i.e. each friend will be reminded by exactly one friend. Note that  p_i = i p i ​ =i is possible, which means that the friend will not remind anyone about Tomori's birthday after sending their wish. The day is over and at the end of the day, Tomori receives the wish from Friend i at time  b_i b i ​ (if b_i = -1 b i ​ =−1, it means that friend i never wished her for her birthday). Note that  b_i b i ​ might not be equal to t_i t i ​ as he or she might be reminded by another friend at an earlier time.  Tomori receives the wishes, but she actually can't distinguish between her friends, so she only knows the number of wishes she received at each particular time. Now, she wonders, over all possible permutations {p_i} {p i ​ }, how many possible different days she could have experienced. Two permutations p, q correspond to different days if at some point of time, the number of friends who wished Tomori was different.

HBC52170翻转卡片,动态规划Birthday Reminders题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC52170翻转卡片 动态规划Birthday Reminders题解