10分,求助大佬们

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

有时候p会大于q,你先判断一下
by 第二小题 @ 2020-05-04 18:10:21


第3个for应该从0开始
by 第二小题 @ 2020-05-04 18:10:55


改这两个就过了
by 第二小题 @ 2020-05-04 18:12:35


```cpp #include<bits/stdc++.h> using namespace std; int n,m,p,q,ans; bool bo[10001]; int main() { cin>>m>>n; for(int i=1;i<=n;i++) { cin>>p>>q; if(p>q) swap(p,q); for(int j=p;j<=q;j++) bo[j]=1; } for(int i=0;i<=m;i++) if(bo[i]==0) ans++; cout<<ans; return 0; } ```
by 第二小题 @ 2020-05-04 18:13:39


谢谢大佬指点!
by dongsir @ 2020-05-04 18:40:06


|