Page 6 of 7

Posted: Wed Sep 05, 2007 4:59 am
by Jan
Try the cases.

Input:

Code: Select all

6 46 25 73 71 30 78
2 15 25
Output:

Code: Select all

Case #1: 46 25 73 71 30 78
This is not an A-sequence.
Case #2: 15 25
This is an A-sequence.
Hope these help.

Re: 10930 - A-Sequence

Posted: Mon Aug 11, 2008 3:29 am
by kantaki
I checked previous posted test case, and got correct answer, I thnk.
But I'm still W.A.
What is my problem with my code?
Please help me.

Code: Select all

Got AC.
I solve this problem without sorting.
Because of sorting, I got WA.

WA: 10930 - A-Sequence

Posted: Wed Feb 11, 2009 9:46 pm
by sazzadcsedu
whats wrong ??
WA.

#include<stdio.h>
#include<memory.h>

int main()

{
int i,j,k,d,sum,a,b,c,rem,r,flag,ncase=1;
int array[31000];
int seque[31];


while(scanf("%d",&d)==1)

{

for(i=0;i<d;i++)
{
scanf("%d",&seque);

}




flag=0;
memset(array,0,sizeof(array));


for(i=0;i<d-1;i++)

{
sum=seque;

for(j=i+1;j<d;j++)

{
a=seque;
b=seque[j];
c=a+b;
// printf("%d %d\n",a,b);

array[c]=1;

sum=sum+b;
array[sum]=1;
//printf("in %d and %d c:%d sum:%d\n",i,j,c,sum);

for(k=i+1;k<j;k++)

{
rem=seque[k];

array[sum-rem]=1;
//printf("in %d and %d and k rem:%d\n",i,j,rem);
}

}
}



/* for(i=1;i<=32;i++)
{
printf("i:%d %d\n",i,array);

}
*/


for(i=1;i<d;i++)

{
r=seque;

if(array[r]==1)
flag=1;

}

printf("Case #%d:",ncase);

for(i=0;i<d;i++)
{
printf(" %d",seque);

}


if(flag==1)
printf("\nThis is not an A-sequence.\n");

else

printf("\nThis is an A-sequence.\n");

ncase++;

}
return 0;

}

Re: 10930 - A-Sequence

Posted: Sun Aug 23, 2009 9:30 am
by stcheung
Just got AC after almost 10 WA. Let me sum up the cases at this point:
(1) If there's duplicate or if the input sequence is NOT in increasing order, then it's NOT an A-sequence. With that said, you do NOT have to sort the input.

(2) Instead of setting the array size as 30000, setting it to 1000 is enough because each number in the input sequence is <= 1000 anyways.

(3) Finally, here's a test input that helps me discover my error:
5 1 10 100 911 1000
My AC code returns "This is an A-sequence." My original error was that when considering the 100, I already know I should reject 11, and so my code would also start rejecting 111, then 211, 311, 411...911 because of the way my loop was (incorrectly) written.

Re: 10930 - A-Sequence

Posted: Thu Oct 08, 2009 2:26 pm
by Jehad Uddin
i have got 11 WAs and then got acc,lots of misunderstanding in the board i think, no need to sort the given no, just have to follow it 1 ? a1 < a2 < a3 < ...,if it breaks then its not A-sequence ,

Re: 10930 - A-Sequence

Posted: Sat Nov 20, 2010 9:00 pm
by sir. manuel
I think that my algorithm it´s fine, but i got WA. I can´t find my error!!!
Can you help me?

Code: Select all

#include<stdio.h>
int main()
{
 	int tam,n=1;  
 	    while(scanf("%d",&tam)==1){
					int aux=tam,vec[tam],indice=0,band=1;			   
						 while(aux--){
						 			   scanf("%d",&vec[indice]);
									   indice++;
									   }	
									   if(vec[0]>=1);
									     else band=0;
									   	   
								   for(int i=1;i<tam;i++){
								   		   if(vec[i]>vec[i-1]);
								   		     else band=0;
											  }
								   if(band==1 && tam>=3){
								   			for(int i=2;i<tam;i++){
												for(int j=0;j<i;j++){
												   for(int k=0;k<i;k++){
												   	  if(k!=j){
													  		if(vec[j]+vec[k]==vec[i]){band=0; break;}   
																 }	   
															  }		
														}	
												}   
										  }
						 printf("Case #%d:",n);
								for(int i=0;i<tam;i++)printf(" %d",vec[i]);  puts("");
						
							    if(band==1){
					           puts("This is an A-sequence.");
								}			  
								else{
									puts("This is not an A-sequence."); 
									 }
								n++;		  
							   }
return 0;	 
}
I read many comments for this problem,...,but i think that is not neccesary order the elements of the sequence...
Only have to check that each Ak>A(n) for n=1,2,...,k-1
And do tho fors to check the sum is the same that Ak...

Re: 10930 - A-Sequence

Posted: Sat Mar 26, 2011 6:53 pm
by DD
One of previous test case:

Code: Select all

3 4 336 34 
Timo's A.C. outputs is:

Code: Select all

Case #1: 4 336 34 
This is an A-sequence.
My A.C. output is:

Code: Select all

Case #1: 4 336 34 
This is not an A-sequence. 
I think there is something wrong in Judge's test data. :o

10930 why RE??

Posted: Wed Apr 04, 2012 2:43 am
by cse.mehedi
:)

Re: 10930 why RE??

Posted: Thu Apr 05, 2012 7:18 pm
by brianfry713
put this line at the end of your code.
return 0;

Re: 10930 why RE??

Posted: Thu Apr 05, 2012 8:36 pm
by cse.mehedi
brianfry713 wrote:put this line at the end of your code.
return 0;
i put return 0; but again shows "the execution of your program didn't finish properly. Remember to always terminate your code with the exit code 0." :(

Re: 10930 why RE??

Posted: Sat Apr 07, 2012 12:37 am
by brianfry713
You are defining arr to have size 0 on it's declaration. The line with just arr[n] doesn't resize the array. There are other issues with your code.

Re: 10930 why RE??

Posted: Sat Apr 07, 2012 9:44 pm
by cse.mehedi
I modified my code but WA! :(

Re: 10930 why RE??

Posted: Mon Apr 09, 2012 9:51 pm
by brianfry713
Don't read from a file.

Re: 10930 why RE??

Posted: Wed Apr 11, 2012 11:38 pm
by cse.mehedi
Give me some test case!!

Re: 10930 why RE??

Posted: Fri Apr 13, 2012 12:36 am
by brianfry713
Don't print a space at the end of the sequence.