Orig Description
B: Mapping
Problem
AOR Ika-chan created a mapping $f:S\rightarrow S$ for a set $S=\{a_1, ..., a_N\}$, where $f(a_i)=b_i$. For any element $x$ in set $S$, determine whether all mappings $g,h:S\rightarrow S$ that satisfy $g(f(x))=h(f(x))$ also satisfy $g(x)=h(x)$. If they do not satisfy this condition, provide a counterexample.
Constraints:
$1 \le N \le 10^5$
$1 \le a_i,b_i \le N$
$a_i \neq a_j \ (i \neq j)$
All input is integers
Input:
$N$
$a_1 \cdots a_N$
$b_1 \cdots b_N$
Output:
If the condition is satisfied, output
Yes
If the condition is not satisfied, provide a counterexample $g(a_i) = c_i, h(a_i) = d_i$, and output
No
$c_1 \cdots c_N$
$d_1 \cdots d_N$
Output a newline character at the end.
Sample
Sample Input 1
5
1 2 3 4 5
3 4 2 5 1
Sample Output 1
Yes
Sample Input 2
5
1 2 3 4 5
3 4 3 5 1
Sample Output 2
No
3 1 5 2 4
3 2 5 2 4
Extracted Specification
An integer N (1 ≤ N ≤ 10^5), representing some quantity or size.
Two lists of integers A and B, each of size N, where each integer is between 1 and N.
The elements of list A are unique.
### Example Input:
```
5
1 2 3 4 5
3 4 2 5 1
```
### Function Signature:
Write a function f(N, A, B) that takes in the input.
```python
def f(N: int, A: List[int], B: List[int]):
'''
N: an integer
A: a list of integers
B: a list of integers
'''
Test Case Generator
Certainly! Below is a test case generator for the given problem statement "B: Mapping".
```python
import random
def tcgen():
N = random.randint(1, 10**5)
# Generate a permutation of [1, 2, ..., N] for a
a = list(range(1, N + 1))
random.shuffle(a)
# Generate a random permutation of [1, 2, ..., N] for b
b = list(range(1, N + 1))
random.shuffle(b)
return N, a, b
# Example usage
N, a, b = tcgen()
print(N)
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))
```
This generator creates a random test case for the problem statement where:
- `N` is the number of elements in the set \( S \).
- `a` is a permutation of the integers from 1 to \( N \) representing the elements in set \( S \).
- `b` is a random permutation of the integers from 1 to \( N \) representing the mappings \( f(a_i) = b_i \).
The generator ensures that all generated values for \( a \) and \( b \) adhere to the specified constraints.
Extract Arguments
def extract_arguments(fh):
N = int(fh.readline().strip())
a = list(map(int, fh.readline().strip().split()))
b = list(map(int, fh.readline().strip().split()))
return N, a, b