CF1620G.Subsequences Galore

提高+/省选-

通过率:0%

时间限制:10.00s

内存限制:1024MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

For a sequence of strings [t1,t2,…,tm][t_1, t_2, \dots, t_m], let's define the function f([t1,t2,…,tm])f([t_1, t_2, \dots, t_m]) as the number of different strings (including the empty string) that are subsequences of at least one string tit_i. f([])=0f([]) = 0 (i. e. the number of such strings for an empty sequence is 00).

You are given a sequence of strings [s1,s2,…,sn][s_1, s_2, \dots, s_n]. 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 2n2^n subsequences of [s1,s2,…,sn][s_1, s_2, \dots, s_n], calculate the value of the function ff modulo 998244353998244353.

对于字符串序列 [t1,t2,…,tm][t_1, t_2, \dots, t_m],定义函数 f([t1,t2,…,tm])f([t_1, t_2, \dots, t_m]) 为:至少是某个字符串 tit_i 的子序列(subsequence)的不同字符串(包括空字符串)的个数。规定 f([])=0f([]) = 0(即空序列对应的该数值为 00)。

给定一个字符串序列 [s1,s2,…,sn][s_1, s_2, \dots, s_n]。该序列中每个字符串均由小写拉丁字母组成,且是有序的(即每个字符串以若干个(可能为零个)字符 a 开头,接着是若干个(可能为零个)字符 b,……,最后以若干个(可能为零个)字符 z 结尾)。

对 [s1,s2,…,sn][s_1, s_2, \dots, s_n] 的全部 2n2^n 个子序列,分别计算函数 ff 的值,并对 998244353998244353 取模。

输入格式

The first line contains one integer nn (1≤n≤231 \le n \le 23) — the number of strings.

Then nn lines follow. The ii-th line contains the string sis_i (1≤∣si∣≤2⋅1041 \le |s_i| \le 2 \cdot 10^4), consisting of lowercase Latin letters. Each string sis_i is sorted.

第一行包含一个整数 nn(1≤n≤231 \le n \le 23)—— 字符串的数量。

接下来是 nn 行。第 ii 行包含字符串 sis_i(1≤∣si∣≤2⋅1041 \le |s_i| \le 2 \cdot 10^4),由小写拉丁字母组成。每个字符串 sis_i 是已排序的。

输出格式

Since printing up to 2232^{23} integers would be really slow, you should do the following:

For each of the 2n2^n subsequences (which we denote as [si1,si2,…,sik][s_{i_1}, s_{i_2}, \dots, s_{i_k}]), calculate f([si1,si2,…,sik])f([s_{i_1}, s_{i_2}, \dots, s_{i_k}]), take it modulo 998244353998244353, then multiply it by k⋅(i1+i2+⋯+ik)k \cdot (i_1 + i_2 + \dots + i_k). Print the XOR of all 2n2^n integers you get.

The indices i1,i2,…,iki_1, i_2, \dots, i_k in the description of each subsequences are 11-indexed (i. e. are from 11 to nn).

由于输出最多 2232^{23} 个整数会非常慢,你需要执行以下操作:

对于全部 2n2^n 个子序列(记为 [si1,si2,…,sik][s_{i_1}, s_{i_2}, \dots, s_{i_k}]),计算 f([si1,si2,…,sik])f([s_{i_1}, s_{i_2}, \dots, s_{i_k}]),对其结果取模 998244353998244353,再乘以 k⋅(i1+i2+⋯+ik)k \cdot (i_1 + i_2 + \dots + i_k)。最后输出所得到的全部 2n2^n 个整数的异或(XOR)值。

在每个子序列的描述中,下标 i1,i2,…,iki_1, i_2, \dots, i_k 采用从 1 开始的索引(即取值范围为 11 到 nn)。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页