Below is my solution for Power Arrangers problem of Code Jam 2019 Round 1C.
When I run this solution with Python interactive tool, It indicates as correct
answer. But, Judge gives me as Wrong Answer. I know there is small mistake that
I need to append null character before printing the answer string. But, without
it also, It works fine. Can anyone please explain me the reason why Judge gives
Wrong Answer though interactive tool indicates the solution as correct answer?
#include <bits/stdc++.h>
using namespace std;
int main() {
//ios_base::sync_with_stdio(0);
//cin.tie(NULL);
//cout.tie(NULL);
int tt, n;
scanf("%d %d",&tt,&n);
for (int qq = 1LL; qq <= tt; qq++) {
char ram[130][7];
memset(ram, 'Z', sizeof ram);
int rA, rB,rC,rD,rE;
char r1,r2,r3,r4,r5;
string ch;
rA=rB=rC=rD=rE=0;
for(int i=1;i<=595;i=i+5)
{
//cout<<i<<endl;
printf("%d\n",i);
fflush(stdout);
//cin>>ch;
cin>>ch;
ram[(i+5)/5][1]=ch[0];
if(ch[0] == 'A') rA++;
else if(ch[0] == 'B') rB++;
else if(ch[0] == 'C') rC++;
else if(ch[0] == 'D') rD++;
else if(ch[0] == 'E') rE++;
}
if(rA==23)
r1 ='A';
else if (rB==23)
r1='B';
else if (rC==23)
r1='C';
else if (rD==23)
r1='D';
else if (rE==23)
r1='E';
rA=rB=rC=rD=rE=0;
for(int i=1;i<=119;i++)
{
if(ram[i][1]==r1){
//cout<<(i-1)*5+2;
printf("%d\n",(i-1)*5+2);
fflush(stdout);
cin>>ch;
//scanf("%c",&ch);
ram[i][2]=ch[0];
if(ch[0] == 'A') rA++;
else if(ch[0] == 'B') rB++;
else if(ch[0] == 'C') rC++;
else if(ch[0] == 'D') rD++;
else if(ch[0]=='E') rE++;
}
}
if(rA==5)
r2 ='A';
else if (rB==5)
r2='B';
else if (rC==5)
r2='C';
else if (rD==5)
r2='D';
else if (rE==5)
r2='E';
rA=rB=rC=rD=rE=0;
for(int i=1;i<=119;i++)
{
if(ram[i][1]==r1 && ram[i][2]==r2){
//cout<<(i-1)*5+3;
printf("%d\n",(i-1)*5+3);
fflush(stdout);
cin>>ch;
//scanf("%c",&ch);
ram[i][3]=ch[0];
if(ch[0]== 'A') rA++;
else if(ch[0] == 'B') rB++;
else if(ch[0] == 'C') rC++;
else if(ch[0] == 'D') rD++;
else if(ch[0] == 'E')rE++;
}}
if(rA==1)
r3 ='A';
else if (rB==1)
r3='B';
else if (rC==1)
r3='C';
else if (rD==1)
r3='D';
else if (rE==1)
r3='E';
rA=rB=rC=rD=rE=0;
for(int i=1;i<=119;i++)
{
if(ram[i][1]==r1 && ram[i][2]==r2 && ram[i][3]==r3){
//cout<<(i-1)*5+4;
//cin>>ch;
printf("%d\n",(i-1)*5+4);
fflush(stdout);
cin>>ch;
//scanf("%c",&ch);
ram[i][4]=ch[0];
if(ch[0] == 'A') rA++;
else if(ch[0] == 'B') rB++;
else if(ch[0] == 'C') rC++;
else if(ch[0] == 'D') rD++;
else if(ch[0] == 'E') rE++;
}
}
if(rA==1)
r5 ='A';
else if (rB==1)
r5='B';
else if (rC==1)
r5='C';
else if (rD==1)
r5='D';
else if (rE==1)
r5='E';
int ram1[5] ={0,0,0,0,0};
ram1[r1-'A']=1;
ram1[r2-'A']=1;
ram1[r3-'A']=1;
ram1[r5-'A']=1;
for(int k=0;k<=4;k++)
if(ram1[k]==0)
r4='A'+k;
char str[5]={r1,r2,r3,r4,r5};
//cout<<str<<endl;
printf("%s\n", str);
fflush(stdout);
string verdict;
//cin>>verdict;
cin>>verdict;
if(verdict != "Y")
exit(0);
}
return 0;
}
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/29d533ec-7d58-4ec7-aef7-900b8c1fdeb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.