## 10474 - Where is the Marble?

All about problems in Volume 104. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Shuvo#
New poster
Posts: 1
Joined: Thu Apr 28, 2011 7:27 pm

### Re: 10474 - Where is the Marble?

Where is the problem ?? I'm continuously getting WA. But can't find out the problem

Code: Select all

``````#include<stdio.h>

int compare (const void * , const void *) ;
int a[1000000] , b[1000000] ;
int main(void)
{

int N , i , v = 0 , Q , j ;

while(++v){

scanf("%d%d",&N,&Q) ;

if(N == 0 && Q == 0)break ;

for(i = 0 ; i < N ; i ++)
{
scanf("%d",&a[i]);
}
for(i = 0 ; i < Q ; i++)
{
scanf("%d",&b[i]) ;
}
qsort(a,N,sizeof(int),compare) ;

printf("CASE# %d:\n",v);
for(i = 0 ; i < Q ; i ++)
{
for(j = 0 ; j < N ; j ++)
{
if(a[j] == b[i])break ;

}
if(a[j] == b[i])printf("%d found at %d\n",b[i],j+1);
}
}
return 0 ;
}

int compare(const void *i , const void *j)
{

return *((const int*)i ) - *((const int*)j ) ;
}
``````

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 10474 - Where is the Marble?

Where is the problem ?? I'm continuously getting WA. But can't find out the problem
Looks like you forgot to add the following line as part of your headers

Code: Select all

`` #include<stdlib.h>``
Try including that and give it a shot.
Check input and AC output for over 7,500 problems on uDebug!

ssavi
New poster
Posts: 28
Joined: Thu Nov 20, 2014 9:57 pm

### Re: 10474 - Where is the Marble?

Code: Select all

``````#include<stdio.h>
int main()
{
long long int m, q, a[100000], b[100000], i, j , p, temp, s, c=0;
while(scanf("%lld %lld",&m,&q)==2 && m<10000 && q<10000)
{
if(m==0 && q==0)
break;
for(i=1;i<=m;i++)
scanf("%lld",&a[i]);
for(j=1;j<=q;j++)
scanf("%lld",&b[j]);
for(i=1; i<=m; i++)
{
for(p=1;p<=(m-i);p++)
{
if(a[p]>a[p+1])
{
temp=a[p+1];
a[p+1]=a[p];
a[p]=temp;
}
}
}
printf("CASE# %lld:\n",++c);
for(j=1;j<=q;j++)
{
s=b[j];
for(i=1; i<=m; i++)
{
if(a[i]==s)
{
printf("%lld found at %lld\n",s,i);
break;
}
}
if(i>m)
{
}
}
}
return 0;
}
``````
@v1n1t . This is my edited code . It passed all test cases in udebug && alumathics inputs . Again I am getting WA . what is the problem ?? please show me .
v1n1t
Last edited by ssavi on Fri Nov 21, 2014 10:25 am, edited 1 time in total.
I know I am a Failure Guy .

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 10474 - Where is the Marble?

ssavi wrote:What is the problem . I am getting WA . Please Help Me Out . I am getting WA & Runtime . Please Help Please .
Try running your code on the input posted by alu_mathics.
Check input and AC output for over 7,500 problems on uDebug!

ssavi
New poster
Posts: 28
Joined: Thu Nov 20, 2014 9:57 pm

### Re: 10474 - Where is the Marble?

Thans v1n1t .. Thank you so much . Your help make my code Accepted . Thank you @v1n1t.

But I have a question . In my code I used break statement to print "found "/ " not found " . But in my ACC code i used another term to print && changed format specifier %lld to %d .Is using " break " statement a problem behind my WA.???
I know I am a Failure Guy .

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10474 - Where is the Marble?

Check input and AC output for thousands of problems on uDebug!