11192 - Group Reverse

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

Moderator: Board moderators

Mister X
New poster
Posts: 5
Joined: Sun Mar 04, 2007 6:08 pm

11192 - Group Reverse

Post by Mister X »

:( no idea why WA on such an easy problem

cut...
Last edited by Mister X on Mon Mar 05, 2007 3:49 pm, edited 1 time in total.
arsalan_mousavian
Experienced poster
Posts: 111
Joined: Mon Jan 09, 2006 6:19 pm
Location: Tehran, Iran
Contact:

Post by arsalan_mousavian »

your program fails on

Code: Select all

1 abcde
the output should be:

Code: Select all

edcba
have fun
In being unlucky I have the record.
Mister X
New poster
Posts: 5
Joined: Sun Mar 04, 2007 6:08 pm

Post by Mister X »

:oops: :oops: :oops: :oops: :oops: :oops:
turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

11192,WA

Post by turcse143 »

HI, everybody i solve this problem but i got WA.
I don't know the problem of my code.

I want more sample input/output.
Is this sample input/output only for the special case:G=1;

Ples help me!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :cry:
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Try the cases.

Input:

Code: Select all

1 ABCDEFGHIJKLMNOPQRSTUVWX
2 ABCDEFGHIJKLMNOPQRSTUVWX
3 ABCDEFGHIJKLMNOPQRSTUVWX
4 ABCDEFGHIJKLMNOPQRSTUVWX
6 ABCDEFGHIJKLMNOPQRSTUVWX
8 ABCDEFGHIJKLMNOPQRSTUVWX
0
Output:

Code: Select all

XWVUTSRQPONMLKJIHGFEDCBA
LKJIHGFEDCBAXWVUTSRQPONM
HGFEDCBAPONMLKJIXWVUTSRQ
FEDCBALKJIHGRQPONMXWVUTS
DCBAHGFELKJIPONMTSRQXWVU
CBAFEDIHGLKJONMRQPUTSXWV
Hope these help.
Ami ekhono shopno dekhi...
HomePage
turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Post by turcse143 »

:) thanks GURU, i got AC
THANKS A LOT
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11192 - Group Reverse

Post by Obaida »

It seemed very easy to me.
I just calculated the length and then divided the length by G to find the group length.
then in next step run a loop to length. and when it's divisible then reverse. :)
try_try_try_try_&&&_try@try.com
This may be the address of success.
maruf
New poster
Posts: 17
Joined: Sat May 24, 2008 6:00 pm

Re: 11192 - Group Reverse

Post by maruf »

thank u shiplu vai
i hv got ac :D
Last edited by maruf on Sun Jun 22, 2008 12:52 pm, edited 1 time in total.
lives for eternity......
shiplu_1320
New poster
Posts: 32
Joined: Sat Dec 29, 2007 9:08 pm
Location: CSEDU , Dhaka
Contact:

Re: 11192 - Group Reverse

Post by shiplu_1320 »

input

Code: Select all

 1 S
your code output a null after S
write the output in a file for this input and see.

Good luck.
A learner......
scofield
New poster
Posts: 2
Joined: Tue Jan 31, 2012 3:20 am

Re: 11192 - Group Reverse

Post by scofield »

Hello, i solved the problem but i always got Wrong Answer, i can't identify what's wrong in the code.
Could you please give me a help to check what's wrong?

Thanks in advance.
scofield
New poster
Posts: 2
Joined: Tue Jan 31, 2012 3:20 am

11192 - Group Reverse

Post by scofield »

Hello, i solved the problem and tested with some sample inputs, the outputs are always right, but when submit i got Wrong Answer, i can't identify what's wrong in the code.
Could you please give me a help to check what's wrong?

Code: Select all

int main()
{
    unsigned char nbrGroups=48, lines=0, offset = 0x00, out_offset=0,
    outstr[100], chars, count, groupSize, i;
    string str;

    //number of groups valid between 0 and 9
    while((nbrGroups >= 48) && (nbrGroups <= 57) && (++lines < 11))
    {
        cin >> nbrGroups;
        cin >> str;
        offset=0;
        out_offset=0;

        if(nbrGroups != 48)
        {
            //calculate the group size
            for(count=0;str[count] != 0x00; count++);

            //check if the total length is multiple of nbrGroups
            if(count%(nbrGroups-48) == 0)
            {
                groupSize = count/(nbrGroups-48);

                //go throught the groups
                for(count=0;count<(nbrGroups-48);count++)
                {
                    //invert the group
                    for(i=offset+groupSize;i != offset ;i--)
                        outstr[out_offset++] = str[i-1];

                    //set the position to the next group
                    offset+=(groupSize);
                }

                outstr[out_offset] = 0x00;
                cout << outstr << endl;
            }
        }
    }

    return 0;
}

Thanks in advance.
nazmus_20000
New poster
Posts: 7
Joined: Fri Dec 14, 2012 9:01 pm

Re: 11192 - Group Reverse

Post by nazmus_20000 »

Please can any one tell why i am getting compiler Error????I m really fed up with this things...

#include<stdio.h>
#include<string.h>
int main()
{
int n,i,j,k,l,t;
char a[1000],b[1000];
while(scanf("%d",&n)!=EOF)
{
if(n==0)break;
else
{
scanf("%s",&a);
l=strlen(a)/n;
for(i=0,j=0;i<n;i++)
{
for(k=0,t=0;t<l;k++,t++)
{
b[k]=a[j];
j++;
}
b[k]='\0';
strrev(b);
printf("%s",b);
}
printf("\n");
}
}
return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11192 - Group Reverse

Post by brianfry713 »

You can see the reason for your Compiler Error by clicking My Submissions.

In this case it's because strrev() isn't included in the judge's compiler. Write your own strrev().
Check input and AC output for thousands of problems on uDebug!
nazmus_20000
New poster
Posts: 7
Joined: Fri Dec 14, 2012 9:01 pm

Re: 11192 - Group Reverse

Post by nazmus_20000 »

Thanks got ac....@brianfry713 :) :) :) :) :) :) :)
sadmansobhan
New poster
Posts: 16
Joined: Thu Oct 10, 2013 8:06 am

Re: 11192 - Group Reverse

Post by sadmansobhan »

Code: Select all

Remove after AC
Last edited by sadmansobhan on Tue Nov 05, 2013 9:15 pm, edited 1 time in total.
Post Reply

Return to “Volume 111 (11100-11199)”