COCI '07 Contest 5 #3 Jabuke

View as PDF

Submit solution

Points: 7
Time limit: 0.6s
Memory limit: 32M

Problem types
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

Ante bought a piece of land. The land contains N apple trees, but his piece is triangular and it is not easy for him to determine which apple trees belong to him.

Your program will be given the coordinates of the vertices of the triangle forming Ante's piece, and the coordinates of all apple trees. Determine the area of land belonging to Ante, and the number of trees belonging to him. We consider apple trees on the very border of his piece to belong to him.

The area of a triangle with vertices (x_A, y_A), (x_B, y_B) and (x_C, y_C) is given by the following formula: \displaystyle \frac{|x_A(y_B-y_C)+x_B(y_C-y_A)+x_C(y_A-y_B)|}{2}

Input Specification

The first three lines contain the coordinates of the vertices of the triangle.

The following line contains the integer N (1 \le N \le 100), the number of apple trees.

Each of the following N lines contains the coordinates of one apple tree. All coordinates are pairs of positive integers less than 1000, separated by a space.

Output Specification

Output the area of land belonging to Ante on the first line, with one digit after the decimal point.

Output the number of tree belonging to Ante on the second line.

Sample Input 1

1 1
5 1
3 3
3 1
3 2
3 3
3 4

Sample Output 1


Sample Input 2

3 2
5 4
1 6
2 4
3 5
4 3

Sample Output 2


Sample Input 3

2 6
5 1
7 8
1 4
3 5
6 4
6 5
4 7

Sample Output 3



There are no comments at the moment.