大佬们请问这题能二分答案吗?

P1983 [NOIP2013 普及组] 车站分级

这题怎么二分啊?等级又固定?@[万岁小姐姐](/space/show?uid=88686)
by 正式AFO @ 2018-11-04 10:40:17


或许是我太菜了,求楼上楼下大佬指点。
by 正式AFO @ 2018-11-04 10:40:50


@[5743377_2002](/space/show?uid=36701) 感觉二分等级数 ``` #include<iostream> #include<cstdio> #include<cstring> using namespace std; #define For(i,j,k) for(register int i=j;i<=k;i++) #define roF(i,j,k) for(register int i=j;i>=k;i--) #define in(a) scanf("%d",&a) #define out(a) printf("%d\n",a) /*----------------------------------------------*/ const int maxn=1e3+5; int n,m,num[maxn],ride[maxn][maxn],level[maxn],ans; inline void Set(int *a,int l,int r,int num){For(i,l,r)a[i]=num;} inline bool check(int g) { Set(level,1,n,1); int maxx=1; For(i,1,m) { } } int main() { in(n);in(m); For(i,1,m){in(num[i]);For(j,1,num[i])in(ride[i][j]);} int l=1;r=n; while(l<=r) { int mid=(l+r)>>1; if(check(mid)){ans=mid;r=mid-1;} else l=mid+1; } out(ans); } ``` 就是想不出怎么打check
by Shirο @ 2018-11-04 10:42:10


不怎么直接好判断是否可以折半。
by 正式AFO @ 2018-11-04 10:45:06


所以。。。。。。
by 正式AFO @ 2018-11-04 10:47:04


@万岁
by 正式AFO @ 2018-11-04 10:47:15


@[万岁小姐姐](/space/show?uid=88686) ~~二分答案做图论凉了,不如用拓扑吧~~
by Le_temps_des_fleurs @ 2018-11-04 10:47:22


@[5743377_2002](/space/show?uid=36701) 对啊,所以我才问qwq
by Shirο @ 2018-11-04 10:49:50


蒟蒻:暴力不好吗?
by orangejuice @ 2018-11-04 10:53:45


NO qwq
by 正式AFO @ 2018-11-04 10:59:50


| 下一页