CF1015APoints in Segments(签到)

Posted myx12345

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF1015APoints in Segments(签到)相关的知识,希望对你有一定的参考价值。

题意:有一条上面有n个点的数轴,给定m次操作,每次覆盖(x[i],y[i]),求最后没有被覆盖过的点的数量与他们的编号

n,m<=100

思路:

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<string>
 4 #include<cmath>
 5 #include<iostream>
 6 #include<algorithm>
 7 #include<map>
 8 #include<set>
 9 #include<queue>
10 #include<vector>
11 using namespace std;
12 typedef long long ll;
13 typedef unsigned int uint;
14 typedef unsigned long long ull;
15 typedef pair<int,int> PII;
16 typedef vector<int> VI;
17 #define fi first
18 #define se second 
19 #define MP make_pair
20 
21 const int N=1100;
22 int a[N],n,m;
23 
24 int read()
25 { 
26    int v=0,f=1;
27    char c=getchar();
28    while(c<48||57<c) {if(c==-) f=-1; c=getchar();}
29    while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
30    return v*f;
31 }
32  
33 int main()
34 {
35   //freopen("1.in","r",stdin);
36   //freopen("1.out","w",stdout);
37   scanf("%d%d",&n,&m);
38   for(int i=1;i<=n;i++) 
39   {
40       int x,y;
41     scanf("%d%d",&x,&y);
42     for(int j=x;j<=y;j++) a[j]=1;
43   }
44   int ans=0;
45   for(int i=1;i<=m;i++) ans+=a[i];
46   printf("%d
",m-ans);
47   for(int i=1;i<=m;i++)
48    if(!a[i]) printf("%d ",i); 
49   return 0;
50 }

 

以上是关于CF1015APoints in Segments(签到)的主要内容,如果未能解决你的问题,请参考以下文章

Vika and Segments - CF610D

CF1108E1 Array and Segments (Easy version)(待更新)

CF429E Points and Segments

CF429EPoints and Segments 欧拉回路

[CF1588E]Eligible Segments

题解CF193D Two Segments