-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd555.cpp
More file actions
45 lines (40 loc) · 822 Bytes
/
d555.cpp
File metadata and controls
45 lines (40 loc) · 822 Bytes
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
#include <cstdio>
#include <algorithm>
#include <cmath>
#define s 500005
#define f(x) for (int i = 0; i < (x); ++i)
using namespace std;
struct dot {
int x,y;
}dots[s];
bool cmp(dot a, dot b){
if(a.x != b.x)
return a.x > b.x;
return a.y > b.y;
}
int main()
{
int times,cases=1;
while(~scanf("%d",×)){
f(times) scanf("%d %d",&dots[i].x,&dots[i].y);
sort(dots,dots+times,cmp);
int y_max=-1,cur_x=-1,count=0;
bool enable[times]={false};
f(times){
if((dots[i].x!=cur_x)||cur_x==-1){
if(dots[i].y > y_max){
enable[i]=true;
count++;
}
}
cur_x=dots[i].x;
y_max= max (y_max , dots[i].y);
}
printf("Case %d:\nDominate Point: %d\n",cases++,count);
f(times)"{
]="
if(enable[times-i-1])
printf("(%d,%d)\n",dots[times-i-1].x,dots[times-i-1].y );
}
return 0;
}