forked from lshtar13/PS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11650.cc
51 lines (39 loc) · 1.17 KB
/
11650.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> cord;
typedef vector<cord> cords;
inline ll cordhash(cord num) { return num.first * 200000 + num.second * 20000; }
cord swp;
void quicksort0(cords &nums, int start, int end)
{
if (start >= end)
return;
cord pivot = nums[start];
int low = start + 1, high = end;
while (low <= high)
{
if (cordhash(nums[low]) <= cordhash(pivot))
++low;
if (cordhash(nums[high]) >= cordhash(pivot))
--high;
if (cordhash(nums[low]) <= cordhash(pivot) && cordhash(nums[high]) >= cordhash(pivot))
swp = nums[low], nums[low] = nums[high], nums[high] = swp;
}
nums[start] = nums[high], nums[high] = pivot;
quicksort0(nums, start, high - 1);
quicksort0(nums, high + 1, end);
}
int main(void)
{
int n;
scanf("%d", &n);
cords nums(n);
for (int i = 0; i < n; ++i)
scanf("%lld %lld", &nums[i].first, &nums[i].second);
// quicksort0(nums, 0, n - 1);
sort(nums.begin(), nums.end());
for (int i = 0; i < n; ++i)
printf("%lld %lld\n", nums[i].first, nums[i].second);
return 0;
}