【CF1015A】Points 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\n",m-ans); 47 for(int i=1;i<=m;i++) 48 if(!a[i]) printf("%d ",i); 49 return 0; 50 }
null