50分求助

P1276 校门外的树(增强版)

@[yangjinxuan123456](/user/1240784) 所有变量和数组初始化为 0 ```cpp #include<bits/stdc++.h> using namespace std; int l,n,a,b,c,ar[10010],cnt1=0,cnt2=0; int main(){ cin>>l>>n; for(int i=0;i<n;i++){ cin>>a>>b>>c; if(!a){ for(int j=b;j<=c;j++){ if(ar[j]==1){ cnt1++; cnt2--; } ar[j]=2; } } else{ for(int j=b;j<=c;j++){ if(ar[j]==2){ ar[j]=1; cnt2++; } } } } cout<<cnt2<<endl<<cnt1; return 0; } ```
by Dream_Creator @ 2024-02-23 15:43:27


@[Dream_Creator](/user/529722) 谢谢,已过
by yangjinxuan123456 @ 2024-02-23 15:51:25


|