Definition 1: A pair of words written in capital letters () is said to form a consonant scale if the number of occurrences of consonants in is greater than the number of occurrences of consonants in .
For example, the pair (MADUIXOT, PRESSEC) form a consonant scale, since MADUIXOT has 4 consonants and PRESSEC has 5. So does the pair (POMA, PLATAN). However, neither (SINDRIA, PRUNA) nor (PERA, KIWI) do form a consonant scale.
Definition 2: A consonant words’ scale of length is a sequence of words (written in capital letters), where every pair of consecutive words of the sequence form a consonant scale.
For example: POMA, MADUIXA, PLATAN, PRESSEC, ALBERCOCS is a consonant words’ scale of words with length 5.
Definition 3: Given a matrix with rows and columns, we say that a sequence of positions of the matrix is scaled if it follows the following form , for holding that , , , .
For example, given a matrix of size , the sequence is a scaled sequence of positions of length 5, that starts at position
To do:
Do a program that, given a word matrix and a natural , traverses the matrix in a row-wise way and computes the first position starting a consonant words’ scale of length in a scaled sequence of positions starting at .
Your program must represent the word matrix by means of the following type:
struct Word {
string contents; // the word
int consonants; // number of occurrences of consonants
};
typedef vector< vector<Word> > WordsMat;
The input is composed by a single case. The case consists of the number of rows , the number of columns of the matrix, and a natural number determining the length of the sequence to be found. Following, we find lines with strings each. Each string is formed only by capital letters.
You must write in a single line: the row number and the column number of the matrix, together with the word in it, where the first (according to a row-wise traversal) consonant words’ scale of length starts when considering a scaled sequence of positions. You must write -1 -1 when the matrix does not have any.
Follow the format as specified on the examples. Follow a good programming style. You may consider (but it is up to you) to include comments within your code.
Author: Unknown
Translator: Maria Blesa
Generation: 2026-01-25T21:34:30.356Z
© Jutge.org, 2006–2026.
https://jutge.org