| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 2048 MB | 11 | 7 | 7 | 63.636% |
You are playing a fantasy game where you start with a row of $n$ power crystals. The $i$-th crystal has energy level $a_i$.
You can perform the following operation any number of times:
Note that you may also choose $l = r$.
You want to craft a specific configuration of crystals with energy levels $b_1, \dots , b_m$. Determine whether it is possible.
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 ≤ t ≤ 500$). The description of the test cases follows.
The first line of each test case contains two integers $n$, $m$ ($1 ≤ m ≤ n ≤ 4000$) — the number of crystals in the initial and target configurations, respectively.
The second line of each test case contains $n$ integers $a_1, a_2, \dots , a_n$ ($1 ≤ a_i ≤ 10^9$) — the energy levels of the initial crystals.
The third line of each test case contains $m$ integers $b_1, b_2, \dots , b_m$ ($1 ≤ b_i ≤ 10^9$) — the desired energy levels of the target crystals.
It is guaranteed that the sum of $n$ over all test cases does not exceed $4000$.
For each test case, output YES if you can transform the initial configuration into the target one, and NO otherwise.
3 5 1 2 4 4 2 3 2 5 2 2 4 4 2 3 4 4 1 1 2 1
YES NO YES
In the first test case:
YES.In the second test case, it is not possible to obtain $[4, 4]$ starting from $[2, 4, 4, 2, 3]$, so the answer is NO.
ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2025 J번