-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3.cpp
53 lines (46 loc) · 846 Bytes
/
p3.cpp
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
52
53
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef struct Pos {
int index, x, y;
};
Pos arr[200001];
bool cmp(Pos a, Pos b) {
if (a.x < b.x) {
return true;
}
else if (a.x == b.x) {
if (a.y < b.y) {
return true;
}
}
return false;
}
int main() {
freopen("input.txt", "r", stdin);
int t;
scanf("%d", &t);
for (int testcase = 1; testcase <= t; testcase++) {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d%d", &arr[i].x, &arr[i].y);
arr[i].index = i + 1;
}
sort(arr, arr + n, cmp);
int nx = arr[0].x;
int ny = arr[0].y;
printf("#%d %d ", testcase, arr[0].index);
for (int i = 1; i < n; i++) {
int cx = arr[i].x;
int cy = arr[i].y;
if (nx < cx && ny > cy) {
printf("%d ", arr[i].index);
nx = cx;
ny = cy;
}
}
printf("\n");
}
return 0;
}