12085 - Mobile Casanova

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

Moderator: Board moderators

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

12085 Mobile Casanova -- Why WA?

Post by uvasarker » Sat Jun 02, 2012 7:38 pm

Anyone help me please. I am getting WA in 12085 Mobile Casanova...
Here is my code:

Code: Select all

#include <cstdio>

int main()
{
    unsigned long long n, prm[100010], tmp[100010],cas=0;
    //freopen("in.txt","r",stdin);
    while(scanf("%llu",&n)==1 & n!=0)
    {
        if(n==0) break;

        for(unsigned long long i=0 ; i<n ; i++)
        {
            scanf("%lu",&prm[i]);
        }
        if(cas>0)
            printf("\n");
        printf("Case %lu:\n",++cas);
        int signal=0;
         unsigned long long deff,z=0,last=0;
        for(unsigned long long i=0 ; i<n ; i++)
        {
            if(signal==0 && last==0)
                printf("0%llu",prm[i]);
            if((prm[i+1]-1)==prm[i])
            {
                signal=1;
                last=prm[i]%10;
                if(last==0)
                    last=prm[i]%100;
                if(last==0)
                    last=prm[i]%1000;
                continue;
            }
            else
            {
                if(signal==1)
                {
                    last=prm[i]%10;
                    if(last==0)
                        last=prm[i]%100;
                    if(last==0)
                        last=prm[i]%1000;
                    if(last==0)
                        last=prm[i]%1000;
                    if(last==0)
                        last=prm[i]%10000;
                    if(last==0)
                        last=prm[i]%100000;
                    if(last==0)
                        last=prm[i]%1000000;
                    if(last==0)
                        last=prm[i]%10000000;
                    if(last==0)
                        last=prm[i]%100000000;
                    if(last==0)
                        last=prm[i]%1000000000;
                    if(last==0)
                        last=prm[i]%10000000000;

                    printf("-%llu",last);
                }
                last=0;
                signal=0;
                printf("\n");
            }
        }
    }
}


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

Re: 12085 Mobile Casanova -- Why WA?

Post by brianfry713 » Mon Jun 04, 2012 11:02 pm

Doesn't match the sample I/O.
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: 12085 Mobile Casanova -- Why WA?

Post by uvasarker » Wed Jun 06, 2012 3:30 pm

Hi boss,
continuously getting W A................
Plz help.

Code: Select all

#include <cstdio>

int main()
{
    unsigned long  n, prm[100010], tmp[100010],cas=0;
    //freopen("in.txt","r",stdin);
    while(scanf("%lu",&n)==1)
    {
        if(n==0) break;

        for(unsigned  long i=0 ; i<n ; i++)
        {
            scanf("%lu",&prm[i]);
        }
        if(cas>0)
            printf("\n");
        printf("Case %lu:\n",++cas);
        int signal=0;
         unsigned long deff,z=0,last=0;
        for(unsigned long i=0 ; i<n ; i++)
        {
            if(signal==0 && last==0)
                printf("0%lu",prm[i]);
            if((prm[i+1]-1)==prm[i])
            {
                signal=1;
                last=prm[i]%10;
                if(last==0)
                    last=prm[i]%100;
                if(last==0)
                    last=prm[i]%1000;
                continue;
            }
            else
            {
                if(signal==1)
                {
                    last=prm[i]%10;
                    if(last==0)
                        last=prm[i]%100;
                    if(last==0)
                        last=prm[i]%1000;
                    if(last==0)
                        last=prm[i]%1000;
                    if(last==0)
                        last=prm[i]%10000;
                    if(last==0)
                        last=prm[i]%100000;
                    if(last==0)
                        last=prm[i]%1000000;
                    if(last==0)
                        last=prm[i]%10000000;
                    if(last==0)
                        last=prm[i]%100000000;
                    if(last==0)
                        last=prm[i]%1000000000;
                    if(last==0)
                        last=prm[i]%10000000000;
                    if(last==0)
                        last=prm[i]%20000000000;

                    printf("-%lu",last);
                }
                last=0;
                signal=0;
                printf("\n");
            }
        }
    }
}


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

Re: 12085 Mobile Casanova -- Why WA?

Post by brianfry713 » Wed Jun 06, 2012 10:59 pm

Print a newline at the end of the output.
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: 12085 Mobile Casanova -- Why WA?

Post by uvasarker » Thu Jun 07, 2012 8:52 pm

Hi Boss,
Continuously I am getting W A. Help me more please.

Code: Select all

Mobile
Last edited by uvasarker on Wed Jun 13, 2012 10:42 am, edited 1 time in total.

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

Re: 12085 Mobile Casanova -- Why WA?

Post by brianfry713 » Fri Jun 08, 2012 1:29 am

Input:

Code: Select all

3
01999999989
01999999990
01999999991
2
01999999989
01999999990
0
AC output:

Code: Select all

Case 1:
01999999989-91

Case 2:
01999999989-90

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: 12085 Mobile Casanova -- Why WA?

Post by uvasarker » Wed Jun 13, 2012 10:40 am

Guru
continuously W A

Code: Select all

    #include <cstdio>

    int main()
    {
        unsigned long  n, prm[100010], tmp[100010],cas=0;
        //freopen("in.txt","r",stdin);
        while(scanf("%lu",&n)==1)
        {
            if(n==0) break;

            for(unsigned  long i=0 ; i<n ; i++)
            {
                scanf("%lu",&prm[i]);
            }
            if(cas>0)
                printf("\n");
            printf("Case %lu:\n",++cas);
            int signal=0;
             unsigned long deff,z=0,last=0;
             if(n==2)
             {
                 if(prm[1]-prm[0]==1)
                 {
                     printf("0%lu",prm[0]);
                            last=prm[1]%10;
                            if(last==0 || last==1 )
                                last=prm[1]%100;
                            if(last==0 || last==1)
                                last=prm[1]%1000;
                            if(last==0 || last==1)
                                last=prm[1]%1000;
                            if(last==0 || last==1)
                                last=prm[1]%10000;
                            if(last==0 || last==1)
                                last=prm[1]%100000;
                            if(last==0 || last==1)
                                last=prm[1]%1000000;
                            if(last==0 || last==1)
                                last=prm[1]%10000000;
                            if(last==0 || last==1)
                                last=prm[1]%100000000;
                            if(last==0 || last==1)
                                last=prm[1]%1000000000;
                            if(last==0 || last==1)
                                last=prm[1]%10000000000;
                            if(last==0 || last==1)
                                last=prm[1]%20000000000;
                            printf("-%lu\n",last);
                 }
                 else{
                    printf("0%lu\n",prm[0]);
                    printf("0%lu\n",prm[1]);
                 }
             }
             else{
                for(unsigned long i=0 ; i<n ; i++)
                {
                    if(signal==0 && last==0)
                        printf("0%lu",prm[i]);
                    if((prm[i+1]-1)==prm[i])
                    {
                        signal=1;
                        last=prm[i]%10;
                        if(last==0)
                            last=prm[i]%100;
                        if(last==0)
                            last=prm[i]%1000;
                        continue;
                    }
                    else
                    {
                        if(signal==1)
                        {
                            last=prm[i]%10;
                            if(last==0 || last==1 )
                                last=prm[i]%100;
                            if(last==0 || last==1)
                                last=prm[i]%1000;
                            if(last==0 || last==1)
                                last=prm[i]%1000;
                            if(last==0 || last==1)
                                last=prm[i]%10000;
                            if(last==0 || last==1)
                                last=prm[i]%100000;
                            if(last==0 || last==1)
                                last=prm[i]%1000000;
                            if(last==0 || last==1)
                                last=prm[i]%10000000;
                            if(last==0 || last==1)
                                last=prm[i]%100000000;
                            if(last==0 || last==1)
                                last=prm[i]%1000000000;
                            if(last==0 || last==1)
                                last=prm[i]%10000000000;
                            if(last==0 || last==1)
                                last=prm[i]%20000000000;

                            printf("-%lu",last);
                        }
                        last=0;
                        signal=0;
                        printf("\n");
                    }

                }
             }
        printf("\n");
        }

        return 0;
    }



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

Re: 12085 Mobile Casanova -- Why WA?

Post by brianfry713 » Wed Jun 13, 2012 11:30 pm

It doesn't match the I/O I posted.
Check input and AC output for thousands of problems on uDebug!

??????
New poster
Posts: 6
Joined: Thu Jun 13, 2013 5:40 am

Re: 12085 Mobile Casanova -- Why WA?

Post by ?????? » Fri Nov 01, 2013 8:13 pm

it shows correct outputs, but i am getting WA... help plz :-?

Code: Select all

#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <iostream>
using namespace std;
long long int F1(long long int x,long long int y)
{
    long long int n(0);
    for(long long int i=x,j=y,d=1; i>0 || j>0 ;i/=10 ,j/=10 ,d*=10 )
    {
        if(i%10 != j%10)
        {
            n= n+ (i%10)*d;
        }
    }
    return n;
}
int main()
{
    int N , n, t(1), temp;
    long long int list[100003];
    while(1)
    {
        scanf("%d",&N);
        if(N==0) break;

        for(n=0;n<N;n++)
        {
            scanf("%d",&list[n]);
        }
        list[N] = list [N-1]+2;

        printf("Case %d:\n",t++);

        n=0;
        bool F;
        F=false;
        for(n=0; n<N; n++)
        {
            if(F==false)
            {
                if(list[n+1] - list[n] == 1)
                {
                    F=true;
                    printf("0%lld-" , list[n]);
                    temp = list[n];
                }
                else
                {
                    printf("0%lld\n" , list[n]);
                }
            }
            else
            {
                if(list[n+1] - list[n] != 1)
                {
                    F=false;
                    printf("%lld\n" , F1(list[n],temp) );
                }
            }
        }
        printf("\n");
    }
}

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

Re: 12085 Mobile Casanova -- Why WA?

Post by brianfry713 » Tue Nov 05, 2013 2:15 am

Try: scanf("%lld",&list[n]);
Check input and AC output for thousands of problems on uDebug!

??????
New poster
Posts: 6
Joined: Thu Jun 13, 2013 5:40 am

Re: 12085 Mobile Casanova -- Why WA?

Post by ?????? » Wed Nov 20, 2013 4:51 pm

help plz, i got 8 times WA in this problem :evil:

Code: Select all

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

long long int ph[100001];
bool flag[100002];

int main()
{
    long long int i,j,n,N,x,y,temp;
    int test = 0;
    while(1)
    {
    scanf("%lld",&N);
    if(!N) break;
    temp=0;
    x=0;
    test++;
    scanf("%lld",&ph[1]);
    memset(flag,false,N+1);
    for(n=2;n<=N;n++)
    {
        scanf("%lld",&ph[n]);
        if(ph[n]-ph[n-1]==1) flag[n-1]=true;
    }
    flag[N] = false;
    printf("Case %d:\n",test);
    for(n=1;n<=N;n++)
    {
        if(!flag[n] && !flag[n-1]) printf("0%lld\n",ph[n]);
        else if(flag[n] && !flag[n-1])  temp=ph[n];
        else if(!flag[n] && flag[n-1])
        {
            printf("0%lld-",temp);
            x=0;
            for(i=temp,j=ph[n],y=1;i || j;y*=10,i/=10,j/=10)
            {
                if(i%10 == j%10) break;
                x = x + ((j%10)*y);
            }
            printf("%lld\n",x);
        }
    }
    printf("\n");
    }
    return 0;
}

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

Re: 12085 Mobile Casanova -- Why WA?

Post by brianfry713 » Wed Nov 20, 2013 10:57 pm

Input:

Code: Select all

101
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0
AC output:

Code: Select all

Case 1:
0100-200

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: 12085 Mobile Casanova -- Why WA?

Post by brianfry713 » Wed Dec 04, 2013 12:37 am

Input:

Code: Select all

12
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0
AC output:

Code: Select all

Case 1:
0199-210

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

mratan16
New poster
Posts: 21
Joined: Fri May 16, 2014 12:36 am

12085 - Mobile Casanova

Post by mratan16 » Sun May 18, 2014 5:07 am

I keep getting WA in my code even if the test cases are correct.
Any help is appreciated

Code: Select all

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <sstream>

using namespace std;

int main()
{
	int n;
	int run=0;

	while (cin>>n)
	{
		run++;
		if(n==0)
		{
			break;
		}
		vector<long>numbers; 
		int l=1; 
		int start=-1; 

		for(int i=0; i<n; ++i)
		{
			long temp;
			cin>> temp;
			numbers.push_back(temp);
		}
		cout << "Case "<< run << ":"<<endl;

		for(int i=0; i<numbers.size(); ++i)
		{

			if(numbers[i+1]!=numbers[i]+1 && start!=-1 && l>1)
			{
				cout << "0"<< numbers[start]<< "-";
				string first, last;

				stringstream a; 
				a<< numbers[start];
				first=a.str();

				stringstream b;
				b<< numbers[i];
				last=b.str();

				int z= first[first.size()-1];
				z+=l;

				int counter=1; 
				while(z>1)
				{
					z/=10; 
					counter++;
				}
				int loc=-1;
			
				for(int i=0; i<first.size(); ++i)
				{
					if(first[i]==last[i])
					{
						loc=i; 
					}
					else if(first[i]!=last[i])
					{
						break; 
					}
				}
				string temp= last.substr(loc+1);
				cout << temp <<endl;

				start=-1;
				l=1;
			}

			if(numbers[i+1]==numbers[i]+1)
			{
				l++;
				if(start==-1)
				{
					start=i; 
				}
			}
			else if(numbers[i]-1!= numbers[i-1])
			{
				cout << "0"<< numbers[i] << endl;
			}

		}
		cout << endl << endl;
		numbers.clear();

		// Dont forget the 0 later on.
	}
}

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

Re: 12085 - Mobile Casanova Why WA?

Post by brianfry713 » Tue May 20, 2014 10:33 pm

Print a blank line after the output for each set of input. Look at the output for sample input for details.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 120 (12000-12099)”