USACO 2023 US Open Contest, PlatinumProblem 1. Pareidolia翻译

翻译: 

USACO 2023 US Open Contest, Platinum

Problem 1. Pareidolia

USACO 2023 年美国铂金公开赛
问题 1. 妄想症

**Note: The time limit for this problem is 4s, twice the default. The memory limit for this problem is 512MB, twice the default.**

 **注意:本问题的时间限制为 4 秒,是默认值的两倍。本问题的内存限制为 512MB,是默认值的两倍。**

Pareidolia is the phenomenon where your eyes tend to see familiar patterns in images where none really exist -- for example seeing a face in a cloud. As you might imagine, with Farmer John's constant proximity to cows, he often sees cow-related patterns in everyday objects. For example, if he looks at the string "bqessiyexbesszieb", Farmer John's eyes ignore some of the letters and all he sees is "bessiebessie".

幻视是一种现象,即你的眼睛倾向于在不存在的图像中看到熟悉的图案--例如在云中看到一张脸。正如你可能想象的那样,由于农夫约翰经常接近奶牛,他经常会在日常物品中看到与奶牛有关的图案。例如,如果他看到 "bqessiyexbesszieb "这个字符串,农夫约翰的眼睛会忽略其中的一些字母,而只看到 "bessiebessie"。

Given a string s, let B(s) represent the maximum number of repeated copies of "bessie" one can form by deleting zero or more of the characters from s. In the example above, B("bqessiyexbesszieb")=2. Furthermore, given a string t, let A(t) represent the sum of B(s) over all contiguous substrings s of t.

给定字符串 s
让 B(s)
 表示从 s 中删除零个或多个字符后,"bessie "的最大重复份数. 在上面的例子中,B("bqessiyexbesszieb")=2. 此外,给定字符串 t,让 A(t)表示 B(s)的所有连续子串 s 的总和.

Farmer John has a string t of length at most 2⋅105 consisting only of characters a-z. Please compute A(t), and how A(t) would change after U (1≤U≤2⋅105) updates,  each changing a character of t. Updates are cumulative.

农民约翰的字符串 t 长度至多为 2⋅105 只由字符 a-z 组成。请计算 A(t)以及 A(t) 在 U (1≤U≤2⋅105)次更新,每次更新都会改变 t 的一个字符. 更新是累积性的。 

INPUT FORMAT (input arrives from the terminal / stdin):
The first line of input contains t
.
The next line contains U
, followed by U
 lines each containing a position p
 (1≤p≤N
) and a character c
 in the range a-z, meaning that the p
th character of t
 is changed to c
.

OUTPUT FORMAT (print output to the terminal / stdout):
Output U+1
 lines, the total number of bessies that can be made across all substrings of t
 before any updates and after each update.
SAMPLE INPUT:
bessiebessie
3
3 l
7 s
3 s
SAMPLE OUTPUT:
14
7
1
7

 

输入格式(输入来自终端 / stdin):
第一行输入包含 t
.
下一行包含 U
,接着是 U
 行,每行包含一个位置 p
 (1≤p≤N
)和一个字符 c
 表示 t 的第 p
字符
 改为 c
.

输出格式(打印输出到终端/stdout):
输出 U+1
 行,即在任何更新之前和每次更新之后,在 t 的所有子串中可以进行的贝叶斯的总数。
 的所有子串中,在任何更新之前和每次更新之后可进行的贝西总数。
输入样本:
bessiebessie
3
3 l
7 s
3 s
样本输出:
14
7
1
7

Before any updates, twelve substrings contain exactly 1 "bessie" and 1 string contains exactly 2 "bessie"s, so the total number of bessies is 12⋅1+1⋅2=14
.

After one update, t
 is "belsiebessie." Seven substrings contain exactly one "bessie."

After two updates, t
 is "belsiesessie." Only the entire string contains "bessie."

SCORING:
Input 2: |t|,U≤300
Inputs 3-5: U≤10
Inputs 6-13: |t|,U≤105
Inputs 14-21: No additional constraints.
Problem credits: Brandon Wang and Benjamin Qi

在任何更新之前,12 个子串正好包含 1 个 "bessie",1 个字符串正好包含 2 个 "bessie",因此bessie总数为 12⋅1+1⋅2=14
.

经过一次更新后,t
 是 "belsiebessie"。有 7 个子串正好包含一个 "bessie"。

经过两次更新后,t
 是 "belsiesessie"。只有整个字符串包含 "bessie"。

评分:
输入 2:|t|,U≤300
输入 3-5: U≤10
输入 6-13: |t|,U≤105
输入 14-21: 无额外限制。
问题归功于 汪文杰、齐本杰

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值