エイシングプログラミングコンテスト2021(AtCoder Beginner Contest 202)
C
Made Up
AtCoder
⌀ 130
原题
← BD →
翻译中…

Problem Statement

翻译中…

Given are three sequences of length $N$ each: $A = (A_1, A_2, \dots, A_N)$, $B = (B_1, B_2, \dots, B_N)$, and $C = (C_1, C_2, \dots, C_N)$, consisting of integers between $1$ and $N$ (inclusive).

翻译中…

How many pairs $(i, j)$ of integers between $1$ and $N$ (inclusive) satisfy $A_i = B_{C_j}$?

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 10^5$
  • $1 \leq A_i, B_i, C_i \leq N$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_N
C_1 C_2 \ldots C_N

翻译中…

Output

翻译中…

Print the number of pairs $(i, j)$ such that $A_i = B_{C_j}$.

翻译中…

样例

Input #1
3
1 2 2
3 1 2
2 3 2
Output #1
4
Four pairs satisfy the condition: $(1, 1), (1, 3), (2, 2), (3, 2)$.
Input #2
4
1 1 1 1
1 1 1 1
1 2 3 4
Output #2
16
All the pairs satisfy the condition.
Input #3
3
2 3 3
1 3 3
1 1 1
Output #3
0
No pair satisfies the condition.
题目信息
题号
abc202_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。