RoAlgo Contest #12 - NiceContest | C. Nice Boring Problem

This was the problem page during the contest. Access the current page here.
Time limit: 0.5s Memory limit: 128MB Input: Output:

There are NN points in a KK-dimensional space, represented by KK-tuples of integers (Pi,1,Pi,2,...,Pi,kP_{i,1}, P_{i,2}, ..., P_{i,k}).

Task

Determine the sum of the squares of the Euclidean distances between all unordered pairs of points, modulo 232{2}^{32}.

Input data

The first line contains the integers NN and KK, with their meaning specified above.
Each of the next NN lines contains a KK-tuplet of integers, representing the coordinate of point ii in KK-dimensional space.

Output data

The first line contains a single integer, the sum of the squares of the Euclidean distances between all unordered pairs of points modulo 232{2}^{32}.

Constraints and clarifications

  • 1N100 0001 \leq N \leq 100 \ 000
  • 1K100 0001 \leq K \leq 100 \ 000
  • 1NK200 0001 \leq NK \leq 200 \ 000
  • 1 000 000 000Pi,j1 000 000 000-1 \ 000 \ 000 \ 000 \leq P_{i,j} \leq 1 \ 000 \ 000 \ 000
  • For tests worth 3030 points, N2K100 000 000{N}^{2} \cdot K \leq 100 \ 000 \ 000
  • It is recommended to use fast I/O

Example 1

stdin

3 2
0 0
0 1
1 1

stdout

4

Explanation

There are K=2K = 2 dimensions.
D(A,B)+D(A,C)+D(B,C)=1+2+1=4D(A, B) + D(A, C) + D(B, C) = 1 + 2 + 1 = 4.

Log in or sign up to be able to send submissions!