#P10785. [NOI2024] 集合
[NOI2024] 集合
Problem Description
Xiao Y and Xiao S are playing a game.
Given a positive integer , define a basic set as a set of size whose elements are within . For example, when , the sets and are both basic sets.
Define a set sequence as a sequence made up of basic sets. For example, is a set sequence, where and are both basic sets.
For a permutation of and a set , define as the set obtained by replacing each element in with , i.e., .
For two set sequences of length , define and to be equivalent if and only if there exists a permutation of such that applying the permutation to yields . That is, for all , .
Given two set sequences of length , there are queries. Each time, Xiao S asks Xiao Y: given , determine whether the set sequence and the set sequence are equivalent.
Time flies, and Xiao S and Xiao Y will also drift apart. And the way we stay connected with someone is to remember, nothing more.
Input Format
The first line contains three positive integers , representing the length of the set sequences, the value range of elements, and the number of queries.
The second line contains positive integers. The -th, -th, and -th integers () are the three elements of . It is guaranteed that these three elements are all in and are pairwise distinct.
The third line contains positive integers. The -th, -th, and -th integers () are the three elements of . It is guaranteed that these three elements are all in and are pairwise distinct.
The next lines each contain two positive integers , representing one query.
Output Format
Output lines. Each line contains a string or , indicating whether the two sequences in the corresponding query are equivalent.
4 4 10
1 2 3 1 2 3 1 2 4 1 2 3
1 2 4 2 3 4 1 2 3 2 3 4
1 1
1 2
1 3
1 4
2 2
2 3
2 4
3 3
3 4
4 4
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
见 set2.in/ans
这个样例满足测试点 1-3 的约束条件。
见 set3.in/ans
这个样例满足测试点 8 的约束条件。
见 set4.in/ans
这个样例满足测试点 15、16 的约束条件。
Hint
[Sample 1 Explanation]
Below, denotes the query with parameters :
- For query , let the permutation be . Then , so the two sequences for this query are equivalent.
- For queries , since but , the two sequences for these queries are all not equivalent.
- For queries , let the permutation be . Then , , , so the two sequences for these queries are all equivalent.
[Constraints]
For all testdata, it is guaranteed that: , , , .
::cute-table{tuack}
| Test Point ID | |||
|---|---|---|---|
Translated by ChatGPT 5