90!!!

P1047 [NOIP2005 普及组] 校门外的树

King_and_Grey @ 2024-05-28 17:11:54

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k,ans;
bool isok[100000];
struct node{
    int begin,end;
}a[105];

signed main(){
    cin >> n >> k;
    memset(isok,true,sizeof(isok));
    for (int i = 1; i <= k; i++){
        cin >> a[i].begin >> a[i].end;
    }
    for(int i = 1; i <= k; i++){
        for(int j = a[i].begin; j <= a[i].end ;j++){
            if(isok[j] == true){
                isok[j] = false;
            }
        }
    }
    for(int i = 1; i <= n ;i++){
        if(isok[i] == true){
            ans++;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

我不懂!!! 明明我考虑了左端点从一开始的情况


by qw1234321 @ 2024-05-28 17:38:26

@greyandking 唐。

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k,ans;
bool isok[100000];
struct node{
    int begin,end;
}a[105];

signed main(){
    cin >> n >> k;
    memset(isok,true,sizeof(isok));
    for (int i = 1; i <= k; i++){
        cin >> a[i].begin >> a[i].end;
    }
    for(int i = 1; i <= k; i++){
        for(int j = a[i].begin; j <= a[i].end ;j++){
            if(isok[j] == true){
                isok[j] = false;
            }
        }
    }
    for(int i = 0; i <= n ;i++){
        if(isok[i] == true){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

by qw1234321 @ 2024-05-28 17:40:24

@greyandking ctj 还 c 第一篇好玩吗。


by King_and_Grey @ 2024-05-28 17:42:01

e......不懂你在说什么,我还是一个xxs

谢谢!!!!!!!!!!!!!!!!!


by fanjiayu666 @ 2024-05-28 18:19:24

@greyandking 说你抄题解(chao'ti'jie----ctj)c=抄


by King_and_Grey @ 2024-05-28 19:22:59

wc!!!!!!!!!!!!!

诽谤!!!!!!!!!!!!!!!

我全程自己打的,我妈还看着呢!!!

@fanjiayu666 相信我


by King_and_Grey @ 2024-05-28 19:26:28

@Flying_hq

[恼]

信不信我给你拉黑

我要准备省赛,哪有心思抄题解!!!


by qw1234321 @ 2024-05-28 19:28:47

@greyandking

https://www.luogu.com.cn/record/160545116 你说说怎么写的。


by King_and_Grey @ 2024-05-28 19:31:25

我怀疑洛谷服务器炸了,就提交了一下题解

不说了,我妈来了


by fanjiayu666 @ 2024-05-28 19:44:56

…………


by lilynan @ 2024-05-28 20:25:32


#include<bits/stdc++.h>
using namespace std;
int a[10005],l,m; 
int main(){
    int x,y;
    cin>>l;
    cin>>m;
    int num;
    num=l+1;
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        for(int j=x;j<=y;j++){
            a[j]++;

        }
    }

    for(int i=0;i<=l;i++){
        if(a[i]>=1) num--;
    }

    cout<<num;
    return 0;
}

| 下一页