SORT2D - 2D-SORT
Given n points in a two dimensional space, sort all the points in ascending order.
(x1, y1) > (x2, y2) if and only if (x1 > x2) or (x1 == x2 and y1 < y2)
Input
The first line consists of an integer t, the number of test cases. Then for each test case the first line consists of an integer n, the number of points. Then the next n lines contains two integers xi, yi which represents the point.
Output
For each test case print the sorted order of the points.
Constraints
1 <= t <= 10
1 <= n <= 100000
-10^9 <= coordinates <= 10^9
NOTE: Strict time limit. Prefer scanf/printf/BufferedReader instead of cin/cout/Scanner.
Example
Input: 1 5 3 4 -1 2 5 -3 3 3 -1 -2 Sample Output: -1 2 -1 -2 3 4 3 3 5 -3
hide comments
li0n_mmn:
2023-02-14 00:10:57
<snip>
|
|
yzs:
2020-10-04 08:59:39
[misleading spoiler]! AC in 0.4 sec 1GO
|
|
suryasis:
2017-04-02 10:04:26
Use printf and scanf and also make sure that use std::sort and comp(point p1,point p2) |
|
jigar:
2016-01-19 18:37:32
HI I AM NOT UNDERSTANDING THE QUESTION
|
|
sunshine:
2014-10-03 20:19:51
getting tle..help plzz..i have done using structure and selection sort
|
|
cegprakash:
2012-09-02 12:34:27
@Prakash: use scanf and printf instead of cin and cout |
|
Prakash:
2012-08-21 17:48:38
i am getting AC on my system but here it shows WA at 0.73sec. i have used pair<> and sort() from STL..Reply soon.. |
Added by: | cegprakash |
Date: | 2012-04-05 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |