Evil Subsequence
Time limit3sMemory limit512 MB
Count the subsequences of a whose equal-and-different pattern matches b exactly, so positions i and j hold equal values in the subsequence precisely when b_i equals b_j.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Hash map
- Solved
- No attempts yet
Problem

It's just a problem to waste your time.
You are given two sequences and .
Two sequences and match if and only if and, for every pair , exactly when .
Output the number of subsequences of that match .
Input
The first line contains two integers and (, ).
The second line contains integers ().
The third line contains integers ().
Output
Output one integer: the answer.