0分求助,好多RE

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

blue_239k @ 2022-10-23 11:09:47

#include <iostream>
using namespace std;
int main(){
    int long long l;
    int m;
    int u[m-1],v[m-1];
    cin>>l>>m;
    for(int k=0;k<=m-1;k++){
        cin>>u[k]>>v[k];
    }
    int p[l-1];
    for(int long long k=0;k<=l-1;k++){
        for(int y=0;y<=m-1;y++){
            if(k>=u[y]&&k<=v[y]){
                if(y==m-1){
                    p[k]=1;
                }
                else{
                    continue;
                }
            }
            else{
                p[k]=0;
            }
        }
    }
    int long long out=0;
    for(int long long k=0;k<=l-1;k++){
        if(p[k]!=1){
            out=out+1;
        }
    }
    cout<<out;
    return 0;
}

大佬解决一下谢谢


by Vergil_Sparda @ 2022-10-23 11:12:16

@blue_239k int u[m-1],v[m-1];要放输入后面


by lizixuan1018 @ 2022-10-23 11:14:10

int u[m-1],v[m-1];
cin>>l>>m;

换个位置


by lizixuan1018 @ 2022-10-23 11:17:00

@blue_239k


by blue_239k @ 2022-10-23 15:36:11

谢谢各位大佬


|