Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

POJ 4036 题目详情

Posted by K10876 at 2018-04-07 15:17:36 on Problem 4036
Cybercrime Donut Investigation
DESCRIPTION
Year 2042. The Internet has evolved to a virtual reality dataspace where crimes are committed every day. The 2041SWERC winner developed an agent that drops a donut every time a crime is committed in the Cyberspace. Each of the donuts has its own signature. The Madrid Police have a huge database with crimes and their donut signatures. Today is your day. Your task is to implement a new agent that looks for the records in the database that bear a strong resemblance to the given signature of a dropped donut found at a new crime scene. Experts in virtual criminology have obtained the best similarity measure between donuts: compute the difference in radius of the internal part of the toroids (holes), compute the difference in radius of the external part of the toroids (tubes), and then add up those differences.

INPUT
The first line of each test case contains n (1 ≤ n ≤ 100,000), the number of donuts in the database. The i-th of the following n lines contains the radius of the hole and radius of the tube of the i-th donut in the database, described by two integers l and w (1 ≤ l, w ≤ 109). After that there is a line containing q (1 ≤ q ≤ 50,000), the number of donuts that you are looking for in the database. Then q lines follow, the i-th of them describing the dimensions of the newly found i-th donut in the same way. Different test cases are separated by a blank line. A line containing ‘-1’ marks the end of the input.

SAMPLE INPUT 
2 
2 3 
3 4 
2 
1 1 
3 4

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

-1

SAMPLE OUTPUT
3 
0

7 
7 
5 
5

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator