-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP1884.cpp
41 lines (40 loc) · 997 Bytes
/
P1884.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
#include<bits/stdc++.h>
using namespace std;
struct node
{
int x1,y1,x2,y2;
};
struct node p[1001];//矩形信息
int book[3030];//离散化
int m[10001][10001];//差分矩阵
int main()
{
int N,pol=-1;
for(int i=0;i<N;i++){
cin>>p[i].x1>>p[i].y1>>p[i].x2>>p[i].y2;
book[++pol]=p[i].x1;
book[++pol]=p[i].y1;
book[++pol]=p[i].x2;
book[++pol]=p[i].y2;
}
sort(book,book+pol);//排序
int uni=unique(book,book+pol)-book;//去重
for(int i=0;i<N;i++)
{
p[i].x1=upper_bound(book,book+uni,p[i].x1)-book;
p[i].y1=upper_bound(book,book+uni,p[i].y1)-book;
p[i].x2=upper_bound(book,book+uni,p[i].x2)-book;
p[i].y2=upper_bound(book,book+uni,p[i].y2)-book;
}//二分索引
for(int i=0;i<N;i++)
{
m[p[i].x1][p[i].y1]++;
m[p[i].x2+1][p[i].y1]--;
m[p[i].x1][p[i].y2+1]--;
m[p[i].x2+1][p[i].y2]++;
}
for(int i=0;i<N;i++)
{
}
return 0;
}