-
Notifications
You must be signed in to change notification settings - Fork 13
/
posters.cpp
65 lines (44 loc) · 1.35 KB
/
posters.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
54
55
56
57
58
59
60
61
62
63
64
65
#include<iostream>
#include<stdio.h>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;
short a[10000000];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
long l,r;
scanf("%d",&n);
long min,max;
scanf("%ld%ld",&l,&r);
min=l;
max=r;
for(int i=l;i<=r;i++)
a[i]=(short)0;
for(short i=1;i<n;i++)
{
scanf("%ld%ld",&l,&r);
if(min>l)
min=l;
if(max<r)
max=r;
for(int j=l;j<=r;j++)
a[j]=i;
}
int count=1;
sort(a+min,a+max+1);
for(int i=min+1;i<=max;i++)
{
if(a[i]!=a[i-1])
count++;
}
printf("%d\n",count);
}
system ("pause");
return 0;
}