[尚未搞定] zoj 2301 Color the Ball

  这题也不难,就是细节太多,弄了半天没过(某媛还说是很水很水的题)…郁闷,先发上来,明天接着修改 ,明白天一定给搞定。多想几组数据测试测试。唉,代码写的乱的,明天还不一定能看懂呢…

算了,头疼,睡觉!! #include long n,i; long w[10000],b[10000];long count,temp; long a,m;char c; long begin,end; int same() { long k=0; long flag = 0; while (k<=count) { if ( (a>=w[k]&&a<=w[k+1]&&m>w[k+1]) ) { w[k+1] = m; flag = 1; //printf("left/n"); } if(m>=w[k]&&m<=w[k+1]&&a=w[k+1]&&a<=w[k]) { w[k] = a; w[k+1] = m; flag = 1; // printf("large/n"); } if (a>=w[k]&&m<=w[k+1]) { flag = 1; //printf("small/n"); } if (a == w[k+1]+1) { w[k+1] = m; flag = 1; //printf("leftbew/n"); } if (m==w[k]-1) { w[k] = a; flag = 1; //printf("rightbew/n"); } k+=2; } return flag; } int bsame() { long k = 0; long flag = 0; while (k<= count) { if(m>=w[k]&&mw[k]&&a<=w[k+1]&&m>=w[k+1]) ) { w[k+1] = a-1; flag = 1; } if (m>=w[k+1]&&a<=w[k]) { w[k+1] = 0; w[k] = 0; //count -=2; flag = 1; } if (mw[k]) { w[count+1] = w[k+1]; w[count] = m+1; w[k+1] = a-1; count+=2; flag = 1; } k+=2; } return flag; } int main(void) { while (scanf("%ld",&n) != EOF ) { count = 0; for (i=0;im) {temp=a,a=m;m=temp;} if (c=='w') { if( count==0 || !same() ) { w[count] = a; w[count+1] = m; count+=2; } } else { if (count==0 || !bsame() ) ; } } for (i=0;im) {temp=a,a=m;m=temp;} same(); } long max = -1; begin = 0;end = 0; for (i=0;i= 0) printf("%d %d/n",begin,end); else printf("Oh, my god/n"); } return 0; } 

这个代码写的也太烂了……诶

你可能感兴趣的:(ACM)