11849 - CD

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

Moderator: Board moderators

ggaammeerr
New poster
Posts: 3
Joined: Sat Nov 15, 2008 6:26 pm
Location: EU

Judge not judging (11849 - CD)

Post by ggaammeerr »

Hello,

My problem is that I have not received verdicts for submissions I made 2 days ago (April 21). I have tried resubmitting yesterday and it didn't work either. I guess the judge is working fine because if I check the last 50 submissions, I can see very recent submissions on the top of the list. It's just that my submissions aren't judged for some reason. Could you please look into it? My UVa username is the same as on this forum (ggaammeerr).

Many thanks.
The beauty of programming lies in simplicity.
opo
New poster
Posts: 2
Joined: Tue Dec 13, 2011 8:51 am

11849 CD ---Why RTE Please help me, please.

Post by opo »

Here is my Code.

Code: Select all

/*Removed Code */
Last edited by opo on Fri Jan 13, 2012 7:03 am, edited 1 time in total.
zhaoyangbt110
New poster
Posts: 1
Joined: Mon Jan 09, 2012 8:48 am

11849 runtime error

Post by zhaoyangbt110 »

can somebody pls help me?

I always got runtime error.

Code: Select all

import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeMap;


class cd {
	public cd(){
		
	}
	
	public static void main(String args[]){
        cd c = new cd();
		ArrayList<Long> answer = new ArrayList<Long>();
		TreeMap <Long,Integer> map = new TreeMap<Long,Integer>();
		Scanner sc = new Scanner (System.in);
		int jack=0,jill=0;
		long num=0;
		Long index= 0L;
		jack = sc.nextInt();
		jill = sc.nextInt();
		while(jack!=0|jill!=0){
			num=0;
			index=0L;
			for(int i=0;i<jack;i++){
				index = sc.nextLong();
				if(map.get(index)==null)
					map.put(index, 1);
				else{
					int t = map.get(index)+1;
					map.put(index, t);
				}
			}
			for(int j=0;j<jill;j++){
				index = sc.nextLong();
				if(map.get(index)!=null&&map.get(index)==1)
					num = num+1;
				else if(map.get(index)!=null&&map.get(index)>1){
					num = num + map.get(index);
					map.put(index, 1);
				}
			}
			answer.add(num);
			jack = sc.nextInt();
			jill = sc.nextInt(); 
		}
		for(int i=0;i<answer.size();i++)
			System.out.println(answer.get(i));
	}
	
}

Thanks!
sudkh
New poster
Posts: 1
Joined: Tue Jan 10, 2012 8:09 pm

sample test cases 11849 cd

Post by sudkh »

Hi,
I think my solution to the above problem is correct but the judge keeps on saying that it is wrong. anyone got any sample test cases i can try with output apart from the one on the website
uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

Re: 11849 CD ---Why WA Please help me, please.

Post by uvasarker »

I am getting WA in 11849 - CD
Please, give me some critical test cases so that I would get rid of this problem. Please
Here, is my code

Code: Select all

#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
	long long n,m;
	while(scanf("%lld %lld",&n,&m)==2)
	{
		 vector <long long> jak, jill;
		if(n==0 && m==0) break;
		long long JA, JI;
		
		for(long long i=0 ; i<n ; i++)
		{
			scanf("%lld",&JA);
			jak.push_back(JA);
		}

		for(long long i=0 ; i<m ; i++)
		{
			scanf("%lld",&JI);
			jill.push_back(JI);
		}
		long long temp=0,sell=0;
		
		if(m>n)
		{
				for(long long i=0 ; i<jill.size() ; i++)
				{
						temp=jill[i];
						for(long long j=0 ; j<jak.size() ; j++)
						{
								if(jak[j]==temp)
								{
										sell++;
								}
								else if(temp>jak[j]) break;
						}
						if(jill[i]>jak[n-1])  break;
				}
		}
		else
		{				
				for(long long i=0 ; i<jak.size() ; i++)
				{
						temp=jak[i];
						for(long long j=0 ; j<jill.size() ; j++)
						{
								if(jill[j]==temp)
								{
										sell++;
								}
								else if(temp>jill[j]) break;
						}
						if(jak[i]>jill[m-1])  break;
				}
		}
		
		printf("%lld\n",sell);
	}
	return 0;	
}

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

Re: 11849 CD ---Why RTE Please help me, please.

Post by brianfry713 »

Try the sample input.
Check input and AC output for thousands of problems on uDebug!
uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

Re: 11849 CD ---Why RTE Please help me, please.

Post by uvasarker »

Hi brother,
Now, I got TLE
Here is my code:

Code: Select all

    #include <cstdio>
    #include <vector>
    #include <iostream>
    using namespace std;

    int main()
    {
       long long n,m;
       while(scanf("%lld %lld",&n,&m)==2)
       {
           vector <long long> jak, jill;
          if(n==0 && m==0) break;
          long long JA, JI;
          
          for(long long i=0 ; i<n ; i++)
          {
             scanf("%lld",&JA);
             jak.push_back(JA);
          }

          for(long long i=0 ; i<m ; i++)
          {
             scanf("%lld",&JI);
             jill.push_back(JI);
          }
          long long sjak=jak.size(), sjil=jill.size();
          long long temp=0,sell=0;
          
          if(m>n)
          {
                for(long long i=0 ; i<sjil ; i++)
                {
                      temp=jill[i];
                      for(long long j=0 ; j<sjak ; j++)
                      {
                            if(jak[j]==temp)
                            {
                                  sell++;
                            }
                            else if(jak[j]>temp) break;
                      }
                      if(jill[i]>jak[n-1])  break;
                }
          }
          else
          {            
                for(long long i=0 ; i<jak.size() ; i++)
                {
                      temp=jak[i];
                      for(long long j=0 ; j<jill.size() ; j++)
                      {
                            if(jill[j]==temp)
                            {
                                  sell++;
                            }
                            else if(jill[j]>temp) break;
                      }
                      if(jak[i]>jill[m-1])  break;
                }
          }
          
          printf("%lld\n",sell);
       }
       return 0;   
    }


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

Re: 11849 CD ---Why RTE Please help me, please.

Post by brianfry713 »

You're searching the entire Jack array for every CD Jill has. Speed it up by taking advantage of the fact that the inputs are already sorted.
Check input and AC output for thousands of problems on uDebug!
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: sample test cases 11849 cd

Post by brianfry713 »

input:

Code: Select all

3 3
1
2
3
1
2
4
10 10
2
4
6
8
10
12
14
16
18
20
1
3
5
7
9
11
13
15
17
19
10 10
2
4
6
8
10
12
14
16
18
20
2
4
6
8
10
12
14
16
18
20
10 10
2
5
6
9
10
13
14
17
18
21
2
4
6
8
10
12
14
16
18
20
0 0
Output:

Code: Select all

2
0
10
5
Check input and AC output for thousands of problems on uDebug!
uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

Re: 11849 CD ---Why RTE Please help me, please.

Post by uvasarker »

Hi,
Brother
Thanks a lots.
Thanks a lots.
Thanks a lots.
Finally I got it ACCCCCCCCCCCC.
Achilies_Saiful_Buet
New poster
Posts: 16
Joined: Wed Mar 28, 2012 7:24 pm
Location: Dhaka,Bangladesh

Re: 11849 CD ---Why RTE Please help me, please.

Post by Achilies_Saiful_Buet »

plz help me understanding this.this code below is getting TLE

Code: Select all

#include<iostream>
#include<cstdio>
#include<map>

using namespace std;
int main()
{
    //freopen("11849in.txt","r",stdin);
    long long int n,m,i,j,count;
     int x;
    map<long int,int>mp;

    while(cin>>n>>m && !(n==0 && m==0))
    {
        mp.clear();
        count=0;
        for(i=0;i<n;i++){cin>>x;mp[x]=1;}
        for(i=0;i<m;i++){cin>>x;if(mp[x]==1)count++;}
        cout<<count<<endl;
    }

}
but this is not--

Code: Select all


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <stack>
#include <string>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#define pb push_back
#define MAX 1000000
using namespace std;
int main()
{ long long int n,m;
while(scanf("%lld %lld",&n,&m)&& (n ||m))
{ int a,val=0;
map <int,int> check;
for(long long int i=1;i<=n;i++)
{
scanf("%d",&a);
check[a]=1;
}
for(long long int i=1;i<=m;i++)
{
scanf("%d",&a);
if(check[a]==1)
val++;

}
cout<<val<<endl;
}

return 0;
}
why???
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11849 CD ---Why RTE Please help me, please.

Post by brianfry713 »

scanf is faster than cin.
Check input and AC output for thousands of problems on uDebug!
Evan72
New poster
Posts: 11
Joined: Sat Apr 28, 2012 2:01 pm

Re: 11849 CD ---Why RTE Please help me, please.

Post by Evan72 »

Code: Select all

#include<stdio.h>
removed after AC
Last edited by Evan72 on Mon Jul 02, 2012 11:54 pm, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11849 CD ---Why RTE Please help me, please.

Post by brianfry713 »

Each catalog number is a positive integer no greater than one billion.
Check input and AC output for thousands of problems on uDebug!
Evan72
New poster
Posts: 11
Joined: Sat Apr 28, 2012 2:01 pm

Re: 11849 CD ---Why RTE Please help me, please.

Post by Evan72 »

brianfry713 wrote:Each catalog number is a positive integer no greater than one billion.
Thank you :)
Post Reply

Return to “Volume 118 (11800-11899)”