Page 1 of 1

Re: 12897 - Decoding Baby Boos

Posted: Sat Dec 20, 2014 7:09 pm
by musfiqur.cse
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;
}


Re: 12897 - Decoding Baby Boos

Posted: Tue Dec 23, 2014 3:12 am
by brianfry713
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

Re: 12897 - Decoding Baby Boos

Posted: Fri Aug 28, 2015 7:39 am
by Shahidul.CSE
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 !!

Re: 12897 - Decoding Baby Boos

Posted: Mon Aug 31, 2015 8:27 pm
by brianfry713
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.

Re: 12897 - Decoding Baby Boos

Posted: Mon Aug 31, 2015 8:35 pm
by Shahidul.CSE
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 ?