Orig Description
Score : 300 points
Problem StatementYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.
How many kinds of items did you get?
Constraints
1 \leq N \leq 2\times 10^5
S_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).
InputInput is given from Standard Input in the following format:
N
S_1
:
S_N
OutputPrint the number of kinds of items you got.
Sample Input 13
apple
orange
apple
Sample Output 12
You got two kinds of items: apple and orange.
Sample Input 25
grape
grape
grape
grape
grape
Sample Output 21
Sample Input 34
aaaa
a
aaa
aa
Sample Output 34
Extracted Specification
An integer N (1 ≤ N ≤ 2×10^5), representing some quantity or size.
A list of N strings, where each string consists of lowercase English letters and has a length between 1 and 10 (inclusive).
### Example Input:
```
3
apple
orange
apple
```
### Function Signature:
Write a function f(N, S) that takes in the input.
```python
def f(N: int, S: List[str]):
'''
N: an integer
S: a list of strings
'''
```
Test Case Generator
Sure! Here is the test case generator for the provided problem statement:
```python
import random
import string
def tcgen():
N = random.randint(1, 2 * 10**5)
S = []
for _ in range(N):
length = random.randint(1, 10)
S_i = ''.join(random.choices(string.ascii_lowercase, k=length))
S.append(S_i)
return N, S
# Example usage
if __name__ == "__main__":
N, S = tcgen()
print(N)
for s in S:
print(s)
```
This generator creates a random number `N` (the number of lottery draws) within the specified range and generates `N` random strings `S_i` with lengths between 1 and 10, consisting of lowercase English letters. You can run this script to generate test cases for the problem.
Here's a brief explanation of each part:
1. `N = random.randint(1, 2 * 10**5)`: This line generates a random integer `N` in the range [1, 200,000].
2. `S = []`: Initializes an empty list to store the strings.
3. The `for` loop runs `N` times, each time generating a random string `S_i`:
- `length = random.randint(1, 10)`: Determines the length of the string `S_i`.
- `S_i = ''.join(random.choices(string.ascii_lowercase, k=length))`: Generates a random string of the determined length using lowercase English letters and appends it to the list `S`.
4. `return N, S`: Returns the generated values `N` and `S`.
You can run the script and it will print an example test case to the standard output.
Extract Arguments
def extract_arguments(fh):
N = int(fh.readline().strip())
S = [fh.readline().strip() for _ in range(N)]
return (N, S)