Programming contests

ECN programozó csapatverseny, 2019. május 11.

May 11, 2019, 10:15 AM – May 11, 2019, 3:15 PM

Shape ECN

Anna is playing with her new game, “The Word Transformer.” The game has the following objective. A word needs to be transformed into another given word using a minimum number of edits with the following operations: insertion, deletion, or substitution of a single character. Unfortunately, the game had a malfunction, and in order for Anna to win the game, she needs to follow the following rules:

  • There are n words to be transformed (with minimal edits).
  • The first word needs to be transformed into ECN.
  • From the second word onward, all the words need to be transformed into a new word that is obtained in the following way:
    • Let d be the minimum number of transformations needed in the previous step.
    • Then, each character of the previously obtained word is replaced with a character that is found at d distance from it in the alphabet. If this character exceeds letter Z, it will continue from letter A.
    • Example: if the previous minimum number of transformations was d = 3, and the previous word was ABZ, then the target word is DEC.
  • The game ends when the minimum number of edits is found for every word.

Input Specification

The first line of the input contains n, the number of words to be transformed (1 < n ≤ 50). This is followed by n words on separate lines, containing only uppercase letters of the English alphabet. The length of the words is at most 100 characters.

Output Specification

Output one number, the number of appearances of “ECN” in the list of target words.

Sample Input 1

  1. 4
  2. IRIDESCENT
  3. EPIPHANY
  4. SUPINE
  5. LUMINESCENCE
download as text file

Output for Sample Input 1

  1. 1
download as text file

Sample Input 2

  1. 3
  2. ECN
  3. ABC
  4. ECN
download as text file

Output for Sample Input 2

  1. 2
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024