Mock CCC '19 Contest 2 S3 - Tudor Tallies Triangular Totals

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 3.0s
Memory limit: 1G

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Tudor has decided to build a triangular pen for his goats!

Tudor has identified N locations on his farm where he can install fence posts. To construct a pen, Tudor will install fence posts at exactly three locations, and then build fences between those fence posts.

For obvious reasons, Tudor must select fence posts such that there is strictly positive area for the goats to roam around inside.

How many different pens can Tudor construct? Two pens are different if a fence post is installed in one but not in the other.


4 \le N \le 3000

In tests worth 5 marks, N \le 10

-10^{18} \le x_i, y_i \le 10^{18}

All fence post candidate locations will be pairwise distinct.

Input Specification

The first line of the input is a single positive integer N.

N lines follow, each containing two space-separated integers x_i and y_i, indicating that a fence post can be installed at (x_i, y_i).

Output Specification

Output, on a single line, the number of distinct triangular pens Tudor can build.

Sample Input

0 0
1 0
2 0
1 1

Sample Output



  • -4
    kevinlu1248  commented on Feb. 10, 2020, 6:14 p.m.

    Is Long Long in C++ enough to store 1e18?

  • -1
    rickywen12345  commented on Feb. 19, 2019, 8:15 p.m. edited

    what does the question mean by "positive space"? How do u generate a triangle with negative space. For the sample test case Im counting 4 triangles. Can someone explain this to me please. Thanks

    Edit: Nvm, realized that 0,0 1,0 and 2,0 make a straight line so it's not a triangle.