| 
 | 
back to boardHelp me please!!! I have WA on #21 ! I'm really puzzled... =( Here is a code :   var  a : array [0..100000] of longint;  i,m,n,k : longint;  big : boolean; procedure vvod; begin  {assign(input,'1.txt'); reset(input);}  read(m,n); k := 0;  for i := m to n do read(a[i]); end; procedure find; begin  if (a[m+1] >= a[m]) then big := true  else big := false;  for i := m + 1 to n do  begin   if big and (a[i] < a[i-1]) then   begin    inc(k);    if (a[i+1] < a[i]) then big := false;   end   else   if not(big) and (a[i] >= a[i-1]) then   begin    inc(k);    if (a[i+1] >= a[i]) then big := true;   end;  end; end; procedure vivod; begin  inc(k); writeln(k); end; begin  vvod;  find;  vivod; end.   Could you give any test for which my program output bad answer? Thanks a lot! Re: Help me please!!! I have WA on #21 ! I'm really puzzled... =( I have WA in test #21 too here is my code: #include <stdio.h>   int main() {   int a,b,f[100003],res,c,i,p;   res=0;   scanf("%d %d",&a,&b);   b=b-a+1;   for(i=0;i<b;i++)     scanf("%d",&f[i]);   if(f[1]>f[0]) c=1;   else c=0;   res++;   for(i=1;i<b;i++){      if(f[i]>f[i-1]){         if(c==1 || c==2) continue;         else{           if((i+1)<b){                 if(f[i+1]>f[i]) c=1;               else if(f[i+1]<f[i]) c=0;               else c=2;           }              res++;         }      }      else if (f[i]<f[i-1]){         p++;         if(c==0 || c==2) continue;         else{           if((i+1)<b){                if(f[i+1]<f[i]) c=0;               else if(f[i+1]>f[i]) c=1;               else c=2;           }           res++;         }      }   }  if(res==0) printf("1\n");  else printf("%d\n",res);   return 0; } So could anyone find an error in previous code? Re: So could anyone find an error in previous code?     Edited by author 29.04.2005 09:45 Re: So could anyone find an error in previous code? I write the programm before has looked forum and get WA21 too. Who solve this problem - help!  |  
  | 
|