Блог пользователя It_Wasnt_Me

Автор It_Wasnt_Me, история, 5 лет назад, По-английски

552D - Vanya and Triangles in this problem, shortly you should count all number of triangles with non-zero area.

My idea was to count all triangle I could which is NC3 then I will subtract zero-area triangles

zero-area triangle will occur if there is 3 points on the same line(horizontal, vertical) or have same diagonal.

Unfortunately I received (Wrong answer) and I can't prove why my solution is wrong, I tested it on several testcases and it gives Right answer.

https://ideone.com/iiuxuP Any help

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

You can try the following input:

3
-2 2
0 1
2 0

Your code prints 1, the correct answer is 0.

  • »
    »
    5 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    Edit: I was wrong, sorry. Yes the solution doesn't take care of all colinear points.