CF1450G.Communism

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Please pay attention to the unusual memory limit in this problem.

In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.

The government has nn workers standing in a row and numbered with integers from 11 to nn from left to right. Their job categories can be represented as a string ss of length nn , where the character sis_i represents the job category of the ii -th worker.

A new law will be approved to increase the equality between the workers. The government decided to make everyone have the same job category by performing the following operation any number of times (possibly zero).

There is a fixed rational parameter k=abk=\frac ab describing how easy it is to convince the public, and it will be used to determine the success of an operation.

In an operation, the government first selects a job category xx with at least one worker at the current moment. Suppose i1,,imi_1,\ldots, i_m ( i1<<imi_1<\ldots<i_m ) are the positions of all the workers with job category xx . If k(imi1+1)mk\cdot (i_m-i_1+1)\le m , the government is able to choose any job category yy with at least one worker at the current moment and change the job category of all workers with job category xx to job category yy .

If it is possible to make all workers have job category xx , we say that xx is obtainable. Can you tell the government the set of obtainable job categories?

输入格式

The first line contains three integers n,a,bn, a, b ( 1n50001 \le n \le 5000 , 1ab1051\le a\le b\le 10^5 ) — the number of workers and the numerator and denominator of the parameter kk , respectively.

The second line contains a string ss of length nn , consisting of lowercase English characters — the job categories of each worker. The characters 't', 'r', 'y', 'g', 'u', and 'b' do not appear in the string ss .

输出格式

Print an integer cc equal to the number of obtainable job categories followed by cc space-separated characters — the obtainable job categories sorted in the lexicographical order.

输入输出样例

  • 输入#1

    7 1 2
    comicom

    输出#1

    3 c m o

说明/提示

The first operation must select the job category 'i' because all other job categories cannot satisfy the condition, therefore 'i' is not obtainable.

Below is showed how to obtain 'c', 'm', and 'o'. The square brackets denote the segment containing all workers of the selected category, the red color denotes this category and the blue color denotes the new category after the change.

  1. Get 'c':
  2. ( com[i]comcom[o]com\texttt{com}\color{red}{\texttt{[i]}}\texttt{com} \rightarrow \texttt{com}\color{#1E90FF}{\texttt{[o]}}\texttt{com} )
  3. ( c[omoco]mc[mmmcm]m\texttt{c}\color{red}{\texttt{[o}}\texttt{m}\color{red}{\texttt{o}}\texttt{c}\color{red}{\texttt{o]}}\texttt{m} \rightarrow \texttt{c}\color{#1E90FF}{\texttt{[m}}\texttt{m}\color{#1E90FF}{\texttt{m}}\texttt{c}\color{#1E90FF}{\texttt{m]}}\texttt{m} )
  4. ( c[mmmcmm]c[cccccc]\texttt{c}\color{red}{\texttt{[mmm}}\texttt{c}\color{red}{\texttt{mm]}} \rightarrow \texttt{c}\color{#1E90FF}{\texttt{[ccc}}\texttt{c}\color{#1E90FF}{\texttt{cc]}} )
  5. Get 'm':
  6. ( com[i]comcom[o]com\texttt{com}\color{red}{\texttt{[i]}}\texttt{com} \rightarrow \texttt{com}\color{#1E90FF}{\texttt{[o]}}\texttt{com} )
  7. ( c[omoco]mc[cmccc]m\texttt{c}\color{red}{\texttt{[o}}\texttt{m}\color{red}{\texttt{o}}\texttt{c}\color{red}{\texttt{o]}}\texttt{m} \rightarrow \texttt{c}\color{#1E90FF}{\texttt{[c}}\texttt{m}\color{#1E90FF}{\texttt{c}}\texttt{c}\color{#1E90FF}{\texttt{c]}}\texttt{m} )
  8. ( [ccmccc]m[mmmmmm]m\color{red}{\texttt{[cc}}\texttt{m}\color{red}{\texttt{ccc]}}\texttt{m} \rightarrow \color{#1E90FF}{\texttt{[mm}}\texttt{m}\color{#1E90FF}{\texttt{mmm]}}\texttt{m} )
  9. Get 'o':
  10. ( com[i]comcom[c]com\texttt{com}\color{red}{\texttt{[i]}}\texttt{com} \rightarrow \texttt{com}\color{#1E90FF}{\texttt{[c]}}\texttt{com} )
  11. ( [comcc]om[mommm]om\color{red}{\texttt{[c}}\texttt{om}\color{red}{\texttt{cc]}}\texttt{om} \rightarrow \color{#1E90FF}{\texttt{[m}}\texttt{om}\color{#1E90FF}{\texttt{mm]}}\texttt{om} )
  12. ( [mommmom][ooooooo]\color{red}{\texttt{[m}}\texttt{o}\color{red}{\texttt{mmm}}\texttt{o}\color{red}{\texttt{m]}} \rightarrow \color{#1E90FF}{\texttt{[o}}\texttt{o}\color{#1E90FF}{\texttt{ooo}}\texttt{o}\color{#1E90FF}{\texttt{o]}} )
首页