Orig Description
C: Matching
Problem
Given a sequence of integers $a_i$ of length $N$, output all integers $K (1 \le K \le N)$ that satisfy the following condition:
Condition:
By arranging $a_1, \cdots, a_K$ appropriately, it matches with $a_{N-K+1}, \cdots, a_N$.
Constraints
$1 \le N \le 10^5$
$1 \le a_i \le 10^9$
All inputs are integers.
Input:
$N$
$a_1 \cdots a_N$
Output:
Output all $K$ that satisfies the condition in ascending order, separated by a space. Print a newline character at the end.
Sample
Sample Input 1
8
5 2 4 9 4 9 2 5
Sample Output 1
1 2 4 6 7 8
Sample Input 2
3
5 7 5
Sample Output 2
1 2 3
Sample Input 3
9
118 118 97 116 97 97 114 110 101
Sample Output 3
9
Extracted Specification
An integer N (1 ≤ N ≤ 10^5), representing some quantity or size.
A list of integers A of size N, where each integer is between 1 and 1e9.
### Example Input:
```
8
5 2 4 9 4 9 2 5
```
### Function Signature:
Write a function f(N, A) that takes in the input.
def f(N: int, A: List[int]):
'''
N: an integer
A: a list of integers
'''
Test Case Generator
To write a test case generator for the "C: Matching" problem, we need to create random sequences of integers that respect the given constraints. Here’s a possible implementation:
```python
import random
def tcgen():
# Generate a random length for the sequence, N
N = random.randint(1, 10**5)
# Generate a random sequence of integers of length N, where each integer is between 1 and 10^9
A = [random.randint(1, 10**9) for _ in range(N)]
return N, A
# Function to format the generated test case into the proper input format
def format_test_case(N, A):
return f"{N}\n{' '.join(map(str, A))}"
# Example Usage
N, A = tcgen()
formatted_test_case = format_test_case(N, A)
print(formatted_test_case)
```
### Explanation:
1. **`tcgen` Function**:
- **N**: Randomly selects an integer between 1 and 100,000 (inclusive) to be the length of the sequence.
- **A**: Generates a list of N random integers, each between 1 and 1,000,000,000 (inclusive).
2. **`format_test_case` Function**:
- Takes the generated values N and A to format them properly as a competitive programming test case input.
- The function produces a string where the first line is the integer N and the second line is the space-separated sequence of integers.
### Example Output:
Running the provided example usage code might produce output like:
```
8
482328738 293847293 849203849 203948203 123456789 987654321 111111111 222222222
```
This output is a well-formed test case for the problem "C: Matching". The sequence length is 8, and it contains 8 randomly generated integers between 1 and 1,000,000,000.
Feel free to run the example usage code to generate different test cases as needed.
Extract Arguments
def extract_arguments(fh):
N = int(fh.readline().strip())
A = list(map(int, fh.readline().strip().split()))
return N, A