Mock CCC '26 S2 - The Quick Brown Fox

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types
Mock Canadian Computing Competition: 2026 Senior #2

The quick brown fox jumps over the lazy dog is a famous sentence that contains all the letters of the English alphabet from a to z. Such a sentence or phrase that have all the letters in the alphabet appear at least once is known as a pangram.

Amelia has a set of S strings, each containing only lowercase alphabetical letters, each with a length of L. She would like to put as many as of them as she can in a bag such that all the strings combined within the bag form a pangram. Unfortunately, the bag can only fit exactly S-1 strings, and so she must choose one to exclude from being within the bag.

For example, if she has the following 3 strings:

  • abcdefghijklmnopqrstuvwxxy
  • abcdefghijklmnopqrstuvwyyz
  • abcdefghijklmnopqrstuvwzzz

Amelia could choose to remove either the 2^\text{nd} or 3^\text{rd} string, and the remaining 2 would form a pangram. However, if she removed the 1^\text{st} string, then the remaining letters would not form a pangram since the letter x would not appear in the remaining strings. In this case, she has 2 choices of strings that she could remove such that the remaining strings form a pangram.

How many of her S strings can she exclude such that the remaining S-1 strings form a pangram?

Input Specification

The first line contains 2 spaced integers S and L, indicating the number of strings and the length of the strings respectively.

The next S lines each contain a string of L lowercase alphabetical characters.

The following table shows how the available 15 marks are distributed.

Marks Bounds on S Bounds on L
3 marks 1 \le S \le 100 1 \le L \le 100
5 marks 1 \le S \le 1\,000 1 \le L \le 1\,000
7 marks 1 \le S \le 10\,000 1 \le L \le 1\,000

Output Specification

Output the number of strings that she could exclude from her set of S strings, such that the remaining ones form a pangram.

Sample Input 1

3 26
abcdefghijklmnopqrstuvwxxy
abcdefghijklmnopqrstuvwyyz
abcdefghijklmnopqrstuvwzzz

Output for Sample Input 1

2

Explanation of Output for Sample Input 1

This is the case from the problem statement.

Sample Input 2

2 1
a
b

Output for Sample Input 2

0

Explanation of Output for Sample Input 2

There is no way to exclude one string such that the other one is a pangram.

Sample Input 3

8 5
yxwvu
tsrqp
onmlk
jihgf
edcba
tnalp
osmqz
rkpzp

Output for Sample Input 3

5

Explanation of Output for Sample Input 3

Amelia could choose to exclude either the 2^\text{nd}, 3^\text{rd}, 6^\text{th}, 7^\text{th}, or 8^\text{th} string.


Comments

There are no comments at the moment.