TreeLine
TCC19 India Qualifiers · 2019-05-04 · by erinn
Problem Statement
A farmer has several trees planted, the locations of which are given in
Constraints
- x will have between 1 and 50 elements, inclusive.
- x and y will have the same number of elements.
- Each element of x will be between 0 and 1000, inclusive.
- Each element of y will be between 0 and 1000, inclusive.
- No elements of x and y will refer to the same point.
{0, 3, 6}
{0, 3, 6}
Returns: 3
All three trees for a line.
{0, 3, 6}
{0, 3, 7}
Returns: 2
Notice the last tree is not in line with the first two.
{0, 3, 6, 20, 12}
{0, 3, 0, 20, 11}
Returns: 3
Trees 0, 1 and 3 line up, the other two do not.
{0, 3, 6, 20, 12}
{0, 3, 0, 19, 0}
Returns: 3
{1}
{2}
Returns: 1
Submissions are judged against all 46 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TreeLine with a public method int longest(vector<int> x, vector<int> y) · 46 test cases · 2 s / 256 MB per case