90分求开导

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

这题正解不是线段树吗...
by aminoas @ 2019-03-25 21:04:37


没错啊
by 初墨 @ 2019-03-25 21:06:52


~~我说用线段树没错~~
by 初墨 @ 2019-03-25 21:07:16


``` #include<bits/stdc++.h> using namespace std; int main() { int l,h,a,b,s=0; cin>>l>>h; int d[l+2]; for(int c=0;c<=l;c++) { d[c]=1; } for(int c=1;c<=h;c++) { cin>>a>>b; for(int f=a;f<=b;f++) { d[f]=0; } } for(int c=1;c<=l+1;c++) { if(d[c]==1) { s++; } } cout<<s; return 0; } ``` @[小二兔2007](/space/show?uid=194587)
by aminoas @ 2019-03-25 21:07:44


@[小二兔2007](/space/show?uid=194587) ```cpp for(int f=a;f<=b;f++) { d[f]=0; } ``` a,b可能等于0,而您是从1开始存的
by 111l @ 2019-03-25 21:07:52


误导萌新,乱棍打死
by _Life_ @ 2019-03-25 21:07:57


其实树状数组也很好做QAQ
by 111l @ 2019-03-25 21:08:45


@[自来也](/space/show?uid=87434) 啊对不起我错了QAQ
by 111l @ 2019-03-25 21:09:24


~~正解线段树树状数组不接受反驳~~
by Chiyoda_Momo @ 2019-03-25 21:24:19


|