12897 - Decoding Baby Boos

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

Moderator: Board moderators

Post Reply
musfiqur.cse
New poster
Posts: 10
Joined: Tue Dec 03, 2013 8:48 pm

Re: 12897 - Decoding Baby Boos

Post by musfiqur.cse » Sat Dec 20, 2014 7:09 pm

Why I am getting WA. My code is here

Code: Select all


#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
#define ll long long
#define mem(a) memset(a,0,sizeof(a));
#define M 10000007

int main()
{
    string ss;
int i,j,k,l,n,m,arr[1001];
char ch,kh;
scanf("%d",&n);
while(n--){
    mem(arr);
for(i=(int)'A';i<=(int)'Z';i++){

        arr[i]=i;

    }
     cin>>ss;
    scanf("%d",&m);

    for(j=0;j<m;j++){
         cin>>ch>>kh;

        for(i=(int)'A';i<=(int)'Z';i++){

            if(arr[i]==(int)kh)
                arr[i]=(int)ch;
            else if(i==(int)kh)
                arr[i]=(int)ch;

        }
     }


     for(i=0;i<ss.size();i++){
        if(isalpha(ss[i])){
            ch=(char)arr[(int)ss[i]];
            cout<<ch;

        }
        else
           cout<<ss[i];


     }
     cout<<endl;


}

return 0;
}


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

Re: 12897 - Decoding Baby Boos

Post by brianfry713 » Tue Dec 23, 2014 3:12 am

Input:

Code: Select all

6
OXOGKDUIAXYHBFUIW_SNTAYPSFUCTIIGUWMT
16
A S
H B
K G
Y Z
S R
Z S
F P
B K
Q E
U D
G R
H C
X F
T T
U Q
I W
SZNCHLXMPRJKCFODZBOUSLXDBLALZHLFGNINYEOBVXMYSPQQQTZHDK_FW_FJGQPBDXDQQSSAODYVH
29
G I
Y Z
C V
O M
S C
Z D
W K
Q I
N M
S V
A P
K F
Y K
O D
B I
R S
R J
E R
F W
A U
X X
I Z
I V
H A
W X
M C
H Y
K Y
B H
XVYXYEJDZEFAGNRKX_EYDPFUGABPAVGMEDICXHVVLQLGCRRZQKMTO
51
D W
Z H
U F
H F
R A
O D
O R
P I
I G
H C
F T
W S
X T
A R
G S
Q C
M L
Q P
W I
I Z
F O
H Y
G T
Z Y
A Q
K J
D G
Z G
A B
V Z
D G
S L
D P
X K
M Z
P I
G R
M X
X N
D N
W Y
G N
W C
F H
I W
E A
L L
D Y
J O
Q C
K V
TTYNU_QP_VOYITBNHVEVNECGIJIVZBCRJQTCEYSTSVF_NGMJAFTC_KJHTGRRXIXGYPYRNEJUOOJQJKZJQHMERK
33
Z U
W C
W S
N T
F S
W O
F B
T K
O P
H U
D H
G C
Y M
H F
V R
L L
P U
P K
D M
E C
S K
O C
M A
P H
B D
K W
A E
T S
A A
S C
Q V
Q F
P F
XIUQJJBSXYSM
30
P F
L F
Y S
S G
J A
V M
S B
I N
U H
C C
B G
K J
E D
U M
H G
N N
V W
O Y
F T
V J
V Q
R Q
G N
X B
D C
I B
K F
K S
G Q
Y E
DRKXTOYRJUIV
26
W Z
D D
G T
U G
N Q
J G
W A
E P
F W
H A
P R
T T
J B
I F
M S
R I
N K
E U
D V
M A
H S
S X
O F
E Z
Z T
K L
AC output:

Code: Select all

OXOBBUUIAXYHHXUII_ANTAYXAXUHTIIBUIMT
EBNEBLWOBEEFEBOIBBOBELWIBLBLBBLBGNGNBEOBEWOBEBQQQTBBIF_BF_BEGQBBIWIQQEEBOIBEB
MKFMFEMFPEUFIXFMM_EFFEUUIFEEFKIMEFEFMPKKMEMIFFFPEMMFF
NNYNZ_QO_QKYINPNBQAQNAKGIJIQZPKQJQNKAYKNKQP_NGYJMPNK_TJBNGQQXIXGYOYQNAJZKKJQJTZJQBYAQT
XIUVKKKOXOOV
DPNSEOYPJERD
Check input and AC output for thousands of problems on uDebug!

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 12897 - Decoding Baby Boos

Post by Shahidul.CSE » Fri Aug 28, 2015 7:39 am

brianfry713 wrote:Input:

Code: Select all

6
OXOGKDUIAXYHBFUIW_SNTAYPSFUCTIIGUWMT
16
A S
H B
K G
Y Z
S R
Z S
F P
B K
Q E
U D
G R
H C
X F
T T
U Q
I W
SZNCHLXMPRJKCFODZBOUSLXDBLALZHLFGNINYEOBVXMYSPQQQTZHDK_FW_FJGQPBDXDQQSSAODYVH
29
G I
Y Z
C V
O M
S C
Z D
W K
Q I
N M
S V
A P
K F
Y K
O D
B I
R S
R J
E R
F W
A U
X X
I Z
I V
H A
W X
M C
H Y
K Y
B H
XVYXYEJDZEFAGNRKX_EYDPFUGABPAVGMEDICXHVVLQLGCRRZQKMTO
51
D W
Z H
U F
H F
R A
O D
O R
P I
I G
H C
F T
W S
X T
A R
G S
Q C
M L
Q P
W I
I Z
F O
H Y
G T
Z Y
A Q
K J
D G
Z G
A B
V Z
D G
S L
D P
X K
M Z
P I
G R
M X
X N
D N
W Y
G N
W C
F H
I W
E A
L L
D Y
J O
Q C
K V
TTYNU_QP_VOYITBNHVEVNECGIJIVZBCRJQTCEYSTSVF_NGMJAFTC_KJHTGRRXIXGYPYRNEJUOOJQJKZJQHMERK
33
Z U
W C
W S
N T
F S
W O
F B
T K
O P
H U
D H
G C
Y M
H F
V R
L L
P U
P K
D M
E C
S K
O C
M A
P H
B D
K W
A E
T S
A A
S C
Q V
Q F
P F
XIUQJJBSXYSM
30
P F
L F
Y S
S G
J A
V M
S B
I N
U H
C C
B G
K J
E D
U M
H G
N N
V W
O Y
F T
V J
V Q
R Q
G N
X B
D C
I B
K F
K S
G Q
Y E
DRKXTOYRJUIV
26
W Z
D D
G T
U G
N Q
J G
W A
E P
F W
H A
P R
T T
J B
I F
M S
R I
N K
E U
D V
M A
H S
S X
O F
E Z
Z T
K L
AC output:

Code: Select all

OXOBBUUIAXYHHXUII_ANTAYXAXUHTIIBUIMT
EBNEBLWOBEEFEBOIBBOBELWIBLBLBBLBGNGNBEOBEWOBEBQQQTBBIF_BF_BEGQBBIWIQQEEBOIBEB
MKFMFEMFPEUFIXFMM_EFFEUUIFEEFKIMEFEFMPKKMEMIFFFPEMMFF
NNYNZ_QO_QKYINPNBQAQNAKGIJIQZPKQJQNKAYKNKQP_NGYJMPNK_TJBNGQQXIXGYOYQNAJZKKJQJTZJQBYAQT
XIUVKKKOXOOV
DPNSEOYPJERD
But for the above same input, my Accepted code gives the following output:

Code: Select all

OXOBBUUIAXYHHXUII_ANTAYXAXUHTIIBUIMT
EBNEBLWOBEEFEBOGBBOBELWGBLBLBBLBGNGNBEOBEWOBEBQQQTBBGF_BF_BEGQBBGWGQQEEBOGBEB
MKFMFEMUPEUUEMFMM_EFUEUUEUEEUKEMEUEUMEKKMEMEUFFPEMMFF
NNYNZ_QO_QKYINONBQAQNANGIJIQZONQJQNNAYKNKQO_NGYJYONN_NJBNGQQXIXGYOYQNAJZKKJQJNZJQBYAQN
XIUVKKKOXOOV
DPNSEOYPJEPD
And uDebug also generates the same output which brianfry713 gave.
How can both code be accepted, where they are generating different output for same input !!
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com

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

Re: 12897 - Decoding Baby Boos

Post by brianfry713 » Mon Aug 31, 2015 8:27 pm

My output is correct, yours is wrong. Wrong code can still be AC, it just means it's correct for the judge's input.
In the second I/O, D->Z->I, yours prints G.
Check input and AC output for thousands of problems on uDebug!

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 12897 - Decoding Baby Boos

Post by Shahidul.CSE » Mon Aug 31, 2015 8:35 pm

brianfry713 wrote:My output is correct, yours is wrong. Wrong code can still be AC, it just means it's correct for the judge's input.
In the second I/O, D->Z->I, yours prints G.
Can I pm you my accepted code, to see where my algorithm is wrong ?
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com

Post Reply

Return to “Volume 128 (12800-12899)”