409040: GYM103426 D Fantastic Three
Memory Limit:512 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
D. Fantastic Threetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output
ExamplesInput
You are given an array of non-negative integers $$$a_1$$$, $$$a_2$$$, ... $$$a_n$$$. Count number of triplets $$$1 \le i < j < k \le n$$$, such that $$$(a_i \oplus a_j) < (a_j \oplus a_k)$$$, where $$$\oplus$$$ is an exclusive OR (XOR) operation.
InputThe first line contains a single integer $$$n$$$ — the number of elements in the array ($$$3 \le n \le 200\,000$$$).
The second line contains $$$n$$$ integer numbers $$$a_i$$$ — elements of the array ($$$0 \le a_i \le 10^{18}$$$).
OutputOutput single integer — the number of triplets.
ScoringSubtask | Score | Constraints |
$$$1$$$ | $$$17$$$ | $$$n \le 100$$$ |
$$$2$$$ | $$$19$$$ | $$$n \le 3\,000$$$ |
$$$3$$$ | $$$18$$$ | $$$n \le 30\,000$$$, $$$a_i \le 50$$$ |
$$$4$$$ | $$$22$$$ | $$$n \le 30\,000$$$ |
$$$5$$$ | $$$24$$$ | No additional constraints |
3 0 1 2Output
1Input
4 0 1 2 3Output
2Input
5 6 1 17 3 11Output
7Input
10 0 1 2 3 4 5 6 7 8 9Output
84