#P3739. Special Squares

    ID: 2748 远端评测题 5000ms 64MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>PKU Campus 2009 (POJ Monthly Contest – 2009.05.17), Doraemonok

Special Squares

Description

There are some points and lines parellel to x-axis or y-axis on the plane. If arbitrary chosen two lines parallel to x-axis and two lines parallel to y-axis, one rectangle, or sometimes a square, will be formed. If a square is formed and there is one or more point in the square or on the side of the square, the square is called a "special square". Please find the number of special squares.

Input

The 1st line contains three positive integer n1, n2 and n3. n1 stands for the number of lines parallel to x-axis, n2 stands for the number of lines parallel to y-axis, n3 stands for the number of points.(0<n1, n2, n3≤1000)
Each of the 2nd line to (n1+1)th line gives an integer y_i (0≤y_i≤1000), means a line with equation y=y_i.
Each of the (n1+2)th line to (n1+n2+1)th line gives an integer x_j (0≤x_j≤1000), means a line with equation x=x_j.
Each of the last three lines gives two integers px_k and py_k (0≤px_k,py_k≤1000), means a point with coordinate (px_k, py_k).

Output

Output one line containing an integer specifies the number of special squares. The test data ensures that the result is less than 2^31

4 4 3
0 2 4 6
0 2 4 6
1 1
3 3
6 6
8

Source

PKU Campus 2009 (POJ Monthly Contest – 2009.05.17), Doraemonok