CF1620G.Subsequences Galore
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For a sequence of strings [t1,t2,…,tm] , let's define the function f([t1,t2,…,tm]) as the number of different strings (including the empty string) that are subsequences of at least one string ti . f([])=0 (i. e. the number of such strings for an empty sequence is 0 ).
You are given a sequence of strings [s1,s2,…,sn] . Every string in this sequence consists of lowercase Latin letters and is sorted (i. e., each string begins with several (maybe zero) characters a, then several (maybe zero) characters b, ..., ends with several (maybe zero) characters z).
For each of 2n subsequences of [s1,s2,…,sn] , calculate the value of the function f modulo 998244353 .
输入格式
The first line contains one integer n ( 1≤n≤23 ) — the number of strings.
Then n lines follow. The i -th line contains the string si ( 1≤∣si∣≤2⋅104 ), consisting of lowercase Latin letters. Each string si is sorted.
输出格式
Since printing up to 223 integers would be really slow, you should do the following:
For each of the 2n subsequences (which we denote as [si1,si2,…,sik] ), calculate f([si1,si2,…,sik]) , take it modulo 998244353 , then multiply it by k⋅(i1+i2+⋯+ik) . Print the XOR of all 2n integers you get.
The indices i1,i2,…,ik in the description of each subsequences are 1 -indexed (i. e. are from 1 to n ).
输入输出样例
输入#1
3 a b c
输出#1
92
输入#2
2 aa a
输出#2
21
输入#3
2 a a
输出#3
10
输入#4
2 abcd aabb
输出#4
124
输入#5
3 ddd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaabbbbbbbbbbbcccccccccccciiiiiiiiiiiiiiiiiiiiiiooooooooooqqqqqqqqqqqqqqqqqqvvvvvzzzzzzzzzzzz
输出#5
15706243380