Number of c’s with an a before and without b between, and number of d’s with an a after and without b between

The input of this exercise is a sequence of characters over {a,b,c,d}. We want to count two things:

Input

The input is a sequence of characters over {a,b,c,d}, in just one line.

Output

The output has two natural numbers, in one line, and separated by a white space:

Observation

It is not allowed to use any massive storage data structure, not even string. Read and treat the input character by character.

Assessment over 10 points:

We understand as fast solution one being correct, with linear cost and able to overcome both the public and private tests. We understand as slow solution one not being fast, but correct and able to overcome the public tests.

Problem information

Author: PRO1

Generation: 2026-01-25T14:02:11.751Z

© Jutge.org, 2006–2026.
https://jutge.org