Darts

All submissions for this problem are available.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Alice and Bob are playing a game. First, Alice throws $N$ darts at a board with dimensions $10^9 \times 10^9$ at random. Each dart hits the board at a point (some of these points may coincide). Then, Bob should answer Alice's $Q$ questions. In each question, Alice chooses two integers $l$ and $r$; Bob should only consider all points hit in throws $l$ through $r$ (inclusive) and compute the distance between the farthest pair of these points. Help Bob find the answers to all queries. ### Input  The first line of the input contains a single integer $N$ denoting the number of points.  $N$ lines follow. For each valid $i$, the $i$th of these lines contains two spaceseparated integers $x_i$ and $y_i$ denoting the coordinates of the point hit with the $i$th dart.  The next line contains a single integer $Q$ denoting the number of queries.  Each of the following $Q$ lines contains two spaceseparated integers $l$ and $r$ describing one query. ### Output For each query, print a single line containing one integer — the square of the maximum distance. (It is guaranteed that this number is an integer.) ### Constraints  $1 \le N, Q \le 50,000$  $1 \le x_i, y_i \le 10^9$ for each $i$  $1 \le l \le r \le N$ ### Subtasks **Subtask #1 (20 points):** $1 \le N, Q \le 200$ **Subtask #2 (30 points):** $1 \le N, Q \le 2000$ **Subtask #3 (50 points):** original constraints ### Example Input ``` 2 1 1 2 2 1 1 2 ``` ### Example Output ``` 2 ``` ### Test Case Generation In each test case, the points $(x_1, y_1), (x_2, y_2), \dots, (x_N, y_N)$ are generated randomly uniformly from the $10^9 \times 10^9$ square.Author:  gainullinildar 
Tester:  kingofnumbers 
Editorial  https://discuss.codechef.com/problems/DARTSEGM 
Tags  computationalgeometry, convexhull, gainullinildar, hard, ltime59, segmenttree 
Date Added:  21042018 
Time Limit:  3 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, 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, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 