Cell Phone TowersProblem code: L1 |
All submissions for this problem are available.
Byteline is currently the largest mobile phone operator in Byteland. They have N cellphone towers at different places in Byteland.
Byteland can be viewed as a two dimensional plane, with each tower or skyscraper described by a point in that plane. Of course, no two points have the same coordinates.
Two towers can only communicate with each other if there is no tower nor skyscraper lying on the straight line segment connecting them.
As the most skillful programmer in the company, Johnny's job is to write a program to help Byteland compute the number of pairs of towers which can communicate with each other.
And once again, Johnny has asked for your help!
Input
The first line contains a number t (about 15) which is the number of test cases. Then t test cases follow. Each test case has the following form.
The first line contains two numbers N and M (1 <= N, M <= 1000), the number of towers and skyscrapers in Byteland.
Each line in the next N lines contains two integers representing the coordinates of the cellphone towers.
Finally, each line in the next M lines contains two integers representing the coordinates of the skyscrapers.
All coordinates have absolute values not larger than 10000.
Output
For each test case, print a single number, describing the number of pairs of towers which can communicate with each other.
Example
Input 1 5 4 -1 -1 1 -1 0 -2 -2 -2 0 0 -1 -2 1 0 -1 1 0 -1 Output 6
Output details

In the above figure, the blue points represent the cell towers and the red points represent the skyscrapers as in the example input. The 6 segments AE, BE, BC, AC, AD and BD correspond to the 6 pairs of towers that can communicate with each other.
| Author: | admin |
| Date Added: | 15-12-2009 |
| Time Limit: | 3 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions
