萌新求助qwq 用了很多数据测试都是对的可还是wa..

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

希望更丰富的展现?使用Markdown
by L_M_ @ 2019-02-14 14:50:58


# 希望更丰富的展现?使用Markdown
by wwlw @ 2019-02-14 14:51:11


希望更丰富的展现?使用Markdown
by 33028120040712wcl @ 2019-02-14 14:51:53


```c #include<stdio.h> #include<iostream> using namespace std; int main() { int i,l,m,k,t,n; int max,min; int add=0; scanf("%d %d",&l,&m); int group[m][2]; for(i=0;i<m;i++) { for(k=0;k<=1;k++) { scanf("%d", &group[i][k]);} }//输入二维数组 起点 终点 for(i=m-1;i>0;i--) { if(group[i][0]<group[i-1][0]) { t = group[i][0],n=group[i][1]; group[i][0]=group[i-1][0],group[i][1]=group[i-1][1]; group[i-1][0]= t , group[i-1][1] = n; } }//给数组排序从小到大(按照起点大小来排/序,并且终点也跟着动 max = group[m-1][1]; min = group[0][0]; for(i=0;i<m-1;i++) { if(group[i][1]<group[i+1][0]) { add+=group[i+1][0]-group[i][1]-1; //统计相邻两组之间有没有重合 } } printf("%d", l-(max-min-add)); return 0; } ```
by ROCKWHALE @ 2019-02-14 14:52:37


这题直接用数组标记有没有在某一点种树就可以了呀@[ROCKWHALE](/space/show?uid=162238)
by BCZSX @ 2019-02-14 14:54:19


不会,下一个
by 绝顶我为峰 @ 2019-02-14 14:55:12


@[ROCKWHALE](/space/show?uid=162238) 排序锅了
by 33028120040712wcl @ 2019-02-14 14:55:57


@[BCZSX](/space/show?uid=126669) 没有想到那个方法qwq 想不通这个错在哪里 、、、哭
by ROCKWHALE @ 2019-02-14 14:58:02


@[33028120040712wcl](/space/show?uid=113024) 如果可以的话可不可以说的详细一点 qwq
by ROCKWHALE @ 2019-02-14 14:59:22


@[ROCKWHALE](/space/show?uid=162238) [排序模板](https://www.luogu.org/blog/Believe-yourself/solution-p1177) ~~ps:这是一位洛谷著名的老前辈的模板~~
by 33028120040712wcl @ 2019-02-14 15:05:25


| 下一页