Connection Status:
Competition Arena > Isoceles
TCI '02 Semifinals 2 · 2002-11-22 · by brett1479 · Brute Force, Geometry
Class Name: Isoceles
Return Type: int
Method Name: howMany
Arg Types: (vector<int>, vector<int>)
Problem Statement

Problem Statement

Given a list of points return how many unique isoceles right triangles use 3 of those points as corners. An isoceles right triangle has 2 sides of equal length and a single right angle (90 degrees). Two isoceles triangles are unique if they differ by at least one point.

Notes

  • xs[K] is the x-coordinate of the Kth point and ys[K] is the y-coordinate of the Kth point

Constraints

  • xs will contain between 3 and 50 elements inclusive
  • ys will contain between 3 and 50 elements inclusive
  • xs and ys will contain the same number of elements
  • Each element of xs will be between -1000000 and 1000000 inclusive
  • Each element of ys will be between -1000000 and 1000000 inclusive
  • There will be no duplicate points
Examples
0)
{0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6}
{0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6}
Returns: 968
1)
{0,1,2}
{0,10,0}
Returns: 0
2)
{0,0,5,5}
{0,5,0,5}
Returns: 4

There are four right isoceles triangles in a square.

3)
{0,0,1,1}
{0,1,2,3}
Returns: 0
4)
{0,1,2,3,4,4}
{0,1,2,3,4,0}
Returns: 3

Submissions are judged against all 77 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class Isoceles with a public method int howMany(vector<int> xs, vector<int> ys) · 77 test cases · 2 s / 256 MB per case

Submitting as anonymous