Programming contests

Andy Poe's Faculty Seminar, June 7, 2018

June 7, 2018, 1:00 PM – June 7, 2018, 5:00 PM

Alphabetic Exclusion

Edgar Stiles has been given a list of words to sort. However, he decided it would be easier for him simply to throw some words away so that the rest of the list (in the same relative order) will be sorted. Sadly, he can't even do this trick without help. That's why you need to do this.

Input Specification

You will be given a set of input cases, each of which will begin with an unsigned decimal integer (representing the size of the list of words, no larger than 1000) followed by <EOLN>. Then will follow the list of words, consisting only of capital letters, of length not exceeding ten, each followed by <EOLN>. The last input case will be followed by “0<EOLN>”.

Output Specification

The output cases should appear in the same order as the input cases. Each output case will be of the form “Case c: You only need to remove c word(s)!” (where c is the number of the input case and w is the SMALLEST number of words that can render the rest of the list sorted by their removal) followed by <EOLN>.

Sample Input

  1. 5
  2. OH
  3. THAT
  4. CAT
  5. IS
  6. HIGH
  7. 5
  8. A
  9. B
  10. C
  11. D
  12. E
  13. 0
download as text file

Output for Sample Input

  1. Case 1: You only need to remove 3 word(s)!
  2. Case 2: You only need to remove 0 word(s)!
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024