The Teleporting Experiment
All submissions for this problem are available.
Teleporting was introduced by Quantum physicists way back in 2050. Then, it used to happen by sending the atoms of a person from one place to another in a stream along the straight line joining the source point to the destination point in almost no time. During Teleportation, the Probability of Location of the Person is not zero along the line joining the source and the destination points, for everywhere else, it is zero.
Once, to find out what happens if two streams "Collide" (Collision is defined as the event when the probability of existence of two people at the same point is non-zero at the same instant), an experiment was done on a group of people.
N and M points were chosen on two parallel lines for teleportation from line 1 to 2 respectively, drawn on the floor of a great hall. A set of M people were teleported from each of the N points on line 1 to each of the points on line 2, all(M x N) at the same instant. How many people will "Collide" in such a manner as described above?
FThe first line of input contains a single integer T (<=30), indicating number of test cases to follow. The first line of each test case contains two integers N and M. The next N and M lines contain the co-ordinates of N and M points respectively.
For each of the test case, the output will contain one line containing the number of people collided in the complete process.
Input: 2 2 4 0 0 1 1 2 1 3 2 4 3 5 4 2 2 9 5 11 6 21 23 23 24 Output: 12 2
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.