Mock CCC would not be a real mock CCC without a data structures problem, would it?
You are given a function that maps
to
.
is zero everywhere except at
points.
You must answer queries, as follows
Query(x_a, y_a, x_b, y_b)
- letbe the multiset of all integers
where
,
, and
is positive. Return
1
if there is a submultiset ofof size
where the three elements of the submultiset, when interpreted as side lengths, form a non-degenerate triangle.
Scoring
To get full marks, your solution must solve all test cases in under 0.5 seconds.
If your solution solves all test cases in under 1 second, you get 7 marks.
If your solution solves all test cases in under 1.5 seconds, you get 3 marks.
If your solution solves all test cases in under 2 seconds, you get 1 mark.
Constraints
Input Specification
The first line contains two integers, and
.
The next lines contain three integers,
,
, and
, indicating that
.
The next line contain four integers,
,
,
, and
.
Output Specification
Output lines. On the
th line, output
Query(x_a, y_a, x_b, y_b)
.
Sample Input
9 5
1 3 3
2 3 1
3 3 4
1 2 1
2 2 5
3 2 9
1 1 2
2 1 6
3 1 5
1 1 1 2
1 1 2 2
1 1 1 3
1 2 3 2
1 1 3 3
Sample Output
0
1
0
0
1
Comments