Please help me, the statement is:
Give N (N <= 10^5) pair (x, y). Count number of triads i, j, k (i != j != k) that (X_i + X_j + X_k) % 3 = 0 and (Y_i +
Y_j + Y_k) % 3 = 0
Example:
Input:
6
1 2
2 5
4 0
8 1
5 3
10 7
Output:
2
Explain: (1,3,6) and (2,4,5)
How many meaningfully different (x, y) pairs can you have?
Only 9 — do the mod 3 first on both x and y. After that it's just combinatorics.
I thought about this idea, but I don't know how to code :(, please explain more about it
Sorry, I said triads but meant (x, y) pairs.
Consider them pairs in groups based on their modulus. There's only a few ways to make a valid triad from the different groups and you can figure out how many of each way based on the counts of the groups.