#P15799. [GESP202603 五级] 找数

    ID: 17868 远端评测题 1000ms 512MiB 尝试: 6 已通过: 2 显示难度普及− 上传者: 标签>二分离散化队列2026双指针 two-pointerGESPbitset哈希表STL

[GESP202603 五级] 找数

Background

Related multiple-choice and true/false questions: https://ti.luogu.com.cn/problemset/1209.

Problem Description

Given an array AA containing nn distinct positive integers and an array BB containing mm distinct positive integers, please help calculate how many numbers appear in both array AA and array BB.

Input Format

The first line contains two integers n,mn, m.

The second line contains nn positive integers a1,a2,,ana_1, a_2, \cdots, a_n representing array AA.

The third line contains mm positive integers b1,b2,,bmb_1, b_2, \cdots, b_m representing array BB.

Output Format

Output one integer, representing the number of values that appear in both array AA and array BB.

3 5
4 2 3
3 1 5 4 6
2

Hint

Sample Explanation

In Sample 1, 44 and 33 appear in both arrays AA and BB.

Constraints

For 40%40\% of the testdata, it is guaranteed that 1n,m10001 \leq n, m \leq 1000.

For 100%100\% of the testdata, it is guaranteed that 1n,m1051 \leq n, m \leq 10^5, 1ai,bi1091 \leq a_i, b_i \leq 10^9.

Translated by ChatGPT 5