Hello, i have been trying to solve this problem for quite a while, i am aware this is kind of a standar geometry/counting problem. However the logic behind the solutions i read its pretty unclear to me, and since there is not outline at all, i decided to ask for the help of the CF community.
Ok, so instead of dropping the link to the statement i'll explain the problem, you are given a set of points (which are less than 1000 points), your task is to tell in how many ways you can combine those points to make an isosceles triangle (no three points are collinear) . I have found many problems that follow this concept, and they just change the number of vertices, so i am pretty sure i want to understand the solution to the problem.
if you can help me, that would be great, thanks! :)
This solution works, if there is no coinciding points, and all coordinates are integers.
Sorry for my poor english
it's a pretty short code O: , i know you count the number of equal distances, however i don't know how it works if you don't check that the side with a different distance connects them ): can you explain me your code?
Edit: I tested the code and gives TLE, this is the statement :
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2481
Firstly, the equilateral triangle can not have integer coordinates of vertices.
Isosceles triangle has two equal sides. These sides have a common vertex. Choose this vertex. After iterate other points. For each point, determine how many of previouse we can use in common base.
One of vesion of this task on russian site.
You explained harder version of that problem. In your expalaration
to make an isosceles triangle (no three points are collinear)
I can put ontrinagles like (2, 2) (1, 1) (0, 0)
prohibited
.In statement:
within each test case no three points are collinear.
modified code:
But it so slow. (map has big constant)
Faster version, which doing same:
sort(b, b + len) is NLogN, so total complexity is N^2LogN
thank you very much, now i fully understand the solution to the problem :)