dalao们求助啊!!,不管怎么弄都是#1#2#3wa,但是自检又没问题

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

@[LxAnC](/user/1242156) wa在这https://www.luogu.com.cn/record/148476804
by LxAnC @ 2024-02-26 22:59:37


在第9行和第10行之间加一行 ```cpp i=1 ```
by Manchester_Is_Blue @ 2024-02-26 23:11:41


这样写(c++) ``` #include <bits/stdc++.h> using namespace std; int main() { int l,m,x,y,ans = 0; cin >> l >> m; int arr[10010]; for (int i = 0; i <= l; i++) { arr[i] = 1; } for (int i = 0; i < m; i++) { cin >> x >> y; for (int j = x; j <= y; j++) { arr[j] = 0; } } for (int i = 0; i <= l; i++) { if (arr[i] == 1) { ans++; } } cout << ans; return 0; } ```
by abc_abc_abc @ 2024-02-28 18:20:47


@[Manchester_Is_Blue](/user/556851) 牛啊 我太垃圾 cpu都干废了 ![cpu干费了]("C:\Users\Dell\Desktop\烧电脑.png")
by abc_abc_abc @ 2024-02-28 18:22:45


@[Manchester_Is_Blue](/user/556851) 谢谢哥,不过加上了还是无法解决
by LxAnC @ 2024-02-28 21:53:54


@[LxAnC](/user/1242156) 再把第7,8行改为 ``` int* p = new int[l+1]; for (int i = 0; i <= l; i++) ```
by Manchester_Is_Blue @ 2024-02-29 16:26:58


@[LxAnC](/user/1242156) 因为 l 这个端点也有树,但你没算进去。
by Manchester_Is_Blue @ 2024-02-29 16:27:52


@[Manchester_Is_Blue](/user/556851) 牛啊,我靠解决了谢谢大佬
by LxAnC @ 2024-03-03 21:07:35


|