一个蒟蒻,第一个AC,剩下的是紫色RE是什么意思

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

datobimake @ 2024-07-04 17:44:41

#include<iostream>
using namespace std;
int main()
{
    int l,m,s,e,a[1001],cnt=0;
    cin >> l >> m;
    for(int i = 0;i <= l;i++)
        a[i] = 1;
    for(int i = 1;i <= m;i++)
    {
        cin >> s >> e;
        for(int j = s;j <= e;j++)
            a[j] = 0;
    }
    for(int i = 0;i <= l;i++)
    {
        if(a[i] == 1)
            cnt++;
    }
    cout << cnt;
    return 0;
}

by zhouzihang1 @ 2024-07-04 17:48:30

@datobimake 10^4 = 10000 \neq 1000


by _Liyx_ @ 2024-07-04 17:57:48

@datobimake 第5行,是a[10005]


by datobimake @ 2024-07-04 21:52:44

@zhouzihang1 谢谢


by datobimake @ 2024-07-04 21:53:11

@Liyx 谢谢


|