HBC51640A-SOUL!,思维How Many Schemes题解

凸凸曼凸凸 算法基础篇 57 0
挑战自我,勇攀编程高峰!全网最全C++题库,助您成为编程达人。
-vertex tree, acyclic bidirectional connected graph painted on the wall. The vertices are conveniently labeled with. in the tree, there is a non-empty setof lowercase letters. Soon, LZR finds a note board saying that for each query. u→v and write down the chosen letters in the order of the directed chain. , and the answer to this query is the number of schemes to choose letters so that the result string. Moreover, the answers to queries may be very large, so they only need to know the answers modulo. Please help them answer the queries to enter the next level.

Gromah and LZR have entered the eighth level. There is an n_{} n ​ -vertex tree, acyclic bidirectional connected graph painted on the wall. The vertices are conveniently labeled with  1, 2, cdots, n 1,2,⋯,n. LZR finds that for every edge e_{} e ​  in the tree, there is a non-empty set of lowercase letters s_e s e ​  above it. Meanwhile, Gromah finds m_{} m ​ strings  t_1, t_2, cdots, t_m t 1 ​ ,t 2 ​ ,⋯,t m ​ and  q_{} q ​ queries  (u_1, v_1), (u_2, v_2), cdots, (u_q, v_q) (u 1 ​ ,v 1 ​ ),(u 2 ​ ,v 2 ​ ),⋯,(u q ​ ,v q ​ ) beside the tree. Soon, LZR finds a note board saying that for each query (u,v)_{} (u,v) ​ , you may choose exactly one letter from  s_e s e ​ for all edges  e_{} e ​ in the chain  u rightarrow v u→v and write down the chosen letters in the order of the directed chain  urightarrow v u→v to form a string  str_{} str ​ , and the answer to this query is the number of schemes to choose letters so that the result string  str_{} str ​ completely contains at least one of the  m_{} m ​ given strings t_1, t_2, cdots, t_m t 1 ​ ,t 2 ​ ,⋯,t m ​ . Moreover, the answers to queries may be very large, so they only need to know the answers modulo 998244353_{} 998244353 ​ . Please help them answer the queries to enter the next level.

HBC51640A-SOUL!,思维How Many Schemes题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)

标签: HBC51640A-SOUL! 思维How Many Schemes题解