Maximum Distance

All submissions for this problem are available.
###Read problem statements in [Hindi](http://www.codechef.com/download/translated/JAN19/hindi/MXDIST.pdf), [Bengali](http://www.codechef.com/download/translated/JAN19/bengali/MXDIST.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/JAN19/mandarin/MXDIST.pdf), [Russian](http://www.codechef.com/download/translated/JAN19/russian/MXDIST.pdf), and [Vietnamese](http://www.codechef.com/download/translated/JAN19/vietnamese/MXDIST.pdf) as well. You are given $N$ points $(x_1, y_1), (x_2, y_2), \ldots, (x_N, y_N)$. You should answer $Q$ queries. In each query, you are given a range $[f, t]$. Consider the points $(x_f, y_f), (x_{f+1}, y_{f+1}), \ldots, (x_t, y_t)$; the answer to a query is the square of the maximum Euclidean distance between any two of these points. ### Input  The first line of the input contains a single integer $N$.  $N$ lines follow. For each $i$ ($1 \le i \le N$), the $i$th of these lines contains two spaceseparated integers $x_i$ and $y_i$.  The next line contains a single integer $Q$.  Each of the next $Q$ lines contains two spaceseparated integers $f$ and $t$ describing a query. ### Output For each query, print a single line containing one integer — the squared maximum distance. ### Constraints  $1 \le N, Q \le 2 \cdot 10^5$  $1 \le f \le t \le N$  $0 \le x_i, y_i \le 2 \cdot 10^5$ for each valid $i$ ### Subtasks **Subtask #1 (15 points):** $1 \le N, Q \le 3,000$, **TL=1.5s** **Subtask #2 (35 points):** the coordinates of all points are chosen uniformly randomly, **TL=5s** **Subtask #3 (50 points):** original constraints, **TL=5s** ### Example Input ``` 11 1 2 2 2 3 0 3 1 3 3 3 4 3 1 3 0 3 3 4 2 5 2 5 5 11 9 11 3 8 4 7 9 10 ``` ### Example Output ``` 16 5 16 9 2 ```Author:  bciobanu 
Editorial  https://discuss.codechef.com/problems/MXDIST 
Tags  bciobanu, convexhull, hard, jan19, rmq, rotatingcaliper, sqrtdecomp, taran_1407 
Date Added:  31122018 
Time Limit:  1.5  5 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, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions