Fun with Squares

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

      Johnny has n squares with edges parallel to coordinate axes on the plane. Given two squares A and B
      let us denote a figure that contains all points of A that do not belong to B as A − B.

      Now Johnny wants to find the number of collections of four distinct squares A, B, C and D such that A − B and C − D are equal up to a parallel shift. Rotation is not allowed.

Input

      The first line of the input file contains n — the number of squares (4 ≤ n ≤ 400). The following n lines describe squares. Each square is described by three integer numbers: x, y and l — the coordinates of its left bottom corner and the length of its edge (−109≤ x; y ≤ 109, 1 ≤ l ≤ 109).

Output

      Output the number of sets of four distinct squares A, B, C and D such that A − B and C − D are equal up to a parallel shift. Collections that contain the same set of squares but differ by square roles are considered different.

Sample Input

4
0 0 3
1 1 1
2 2 1
1 1 3
4
0 0 3
1 1 3
2 2 3
4 4 3

Sample Output

6
6

Hint

单组数据

Source

Andrew Stankevich Contest 22

Manager

Information
Solved Number4
Submit Number15
Problem Tags
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel