提交答案题

Crahc with a String

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Crahc gives you a string SS consisting a,b\texttt{a},\texttt{b} and c\texttt{c}. Denote the length of SS as n(1n104)n\,(1\leq n\leq 10^4).

You need to convert SS into the decimal representation of nn. For example, convert the string abbac\texttt{abbac} into 5\texttt{5}.

Each conversion step involves two strings X,Y(X,Y104)X,Y\,(|X|,|Y|\leq 10^4), where XX is not a substring of YY (also, XX is not empty). Note that both XX and YY can only consist of lowercase letters or digits. The single conversion step is defined as follows:

  1. Find the first occurrence of XX in SS.
  2. Replace the first occurrence of XX with YY.
  3. Repeat the above steps until no more occurrences of XX can be found in SS.

Crahc is impatient, so you can only perform up to 2020 steps. At any time (including when performing one step), the length of SS should not exceed 10410^4.

Note that this problem does not require any input. You are only required to provide the steps for your conversion. Your solution must work for all valid strings.

Format

The first line contains a single integer k(1k20)k\,(1\leq k\leq 20), the number of conversion steps you will perform.

The next kk lines, each line contains two strings X,YX,Y, separated by a comma, representing the conversion step from XX to YY.

Samples

The example is for illustration of the format only; it may be incorrect.

3
bb,
ac,2x
a2x,5

It works for S=abbacS=\texttt{abbac}.

Hello ACM 2025

未参加
状态
已结束
规则
ACM/ICPC
题目
11
开始于
2025-8-14 13:00
结束于
2025-8-14 18:00
持续时间
5 小时
主持人
参赛人数
46