美文网首页
CodeFoeces-1015A

CodeFoeces-1015A

作者: ss5smi | 来源:发表于2018-09-15 18:24 被阅读0次

题目

原题链接:A. Points in Segments

题意

问在1m中n个lr片段有多少不在任意片段的点

代码

#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,m,s[101]={0};
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        for(int j=l;j<=r;j++){
            s[j]=1;
        }
    }
    int cnt=0;
    for(int i=1;i<=m;i++){
        cnt+=s[i]?0:1;
    }
    printf("%d\n",cnt);
    for(int i=1;i<=m;i++){
        if(!s[i]){
            printf("%d",i);
            printf("%c",i==m?'\n':' ');
        }
    }
    return 0;
}

相关文章

  • CodeFoeces-1015A

    题目 原题链接:A. Points in Segments 题意 问在1m中n个lr片段有多少不在任意片段的点 代码

网友评论

      本文标题:CodeFoeces-1015A

      本文链接:https://www.haomeiwen.com/subject/onqdvftx.html