zoukankan      html  css  js  c++  java
  • 【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
    ",m-ans);
    47   for(int i=1;i<=m;i++)
    48    if(!a[i]) printf("%d ",i); 
    49   return 0;
    50 }
  • 相关阅读:
    LeetCode 79. 单词搜索
    LeetCode 1143. 最长公共子序列
    LeetCode 55. 跳跃游戏
    LeetCode 48. 旋转图像
    LeetCode 93. 复原 IP 地址
    LeetCode 456. 132模式
    LeetCode 341. 扁平化嵌套列表迭代器
    LeetCode 73. 矩阵置零
    LeetCode 47. 全排列 II
    LeetCode 46. 全排列
  • 原文地址:https://www.cnblogs.com/myx12345/p/9842904.html
Copyright © 2011-2022 走看看