[gcj] Re: Codejam 2019 1C Power Arrangers TLE
Also, You have to include new line character '\n' at the end of printf statement always. Else it will give TLE. -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/2cae43f9-36e4-4c6c-a539-854e644d4596%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[gcj] Re: Solution gives correct answer with Python Interactive Tool. But Judge gives Wrong Answer
Hi Robert, I used the same compiler flags "g++ Solution.cc -std=c++14 -pthread -O3 -o Solution" command to execute the program. Still It worked with interactive tool but not with Judge. Do you actually mean a program will not have the same behaviour with our compiler and Judge compiler?. If so, then how can we be so sure about the correctness of the solution? How can we come to know this difference and rectify? -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/8a159b7e-1577-489b-ab83-e107012ba958%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[gcj] Solution gives correct answer with Python Interactive Tool. But Judge gives Wrong Answer
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 using namespace std; int main() { //ios_base::sync_with_stdio(0); //cin.tie(NULL); //cout.tie(NULL); int tt, n; scanf("%d %d",,); 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<>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",); 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",); 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",); 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<>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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. 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.
[gcj] Re: Code Jam 2019 Round 1C Power Arrangers problem gives me WA. Please help.
It turns out that I should use scanf(" %c",); instead of scanf(" %c",); not to accept previously entered new characters. Also, between the below lines, char str[5]={r1,r2,r3,r4,r5}; printf("%s\n", str); I have to add str[5]='\0';. Then only it gets accepted. Infact, if I add this single line str[5]='\0'; on my last 7th submission of the contest, it gives accepted. So, The only issue I did not figure out is to add this null escape character or I should have strict with cin/cout with which I started out initially. I think I am very unlucky to miss Round 2 just because of this very small format issues. Can anyone tell me if there is someway to convince Google Code Jam team to make me qualify for Round 2? -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/020b5600-edb1-4401-bf84-5f3f833a87fc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[gcj] Re: Code Jam 2019 Round 1C Power Arrangers problem gives me WA. Please help.
It seems there is huge difference between scanf & cin in accepting characters. In case of cin, it works as expected. But in case of scanf, instead of accepting the required character, it is accepting the new line character which got printed by previous printf statement. I checked this behaviour by running the program. Can someone please confirm if my program with printf/scanf fails because of this difference between cout/cin? -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/2a41eb03-346e-467e-b0f9-140856defb45%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[gcj] Re: Code Jam 2019 Round 1C Power Arrangers problem gives me WA. Please help.
Thank you, john.smith for pointing out the mistake. The above code was from my 5th submission. In fact in my last 7th submission, I corrected the first mistake of accepting char using scanf. Instead I used string and cin. So, the only remaining mistake in my 7th submission was char str[5]={r1,r2,r3,r4,r5}; But it ran fine with python interactive tool. It indicated that it is the right answer. It seems there is some conflict between online judge and the python interactive tool. That is why Judge gave Wrong Answer though It passed in interactive tool. I don't know what I am going to do since I fail to qualify for Round 2. I used to strongly believe that with some preparation I am capable of achieving perfect score in World Finals since I have sound knowledge of both Mathematics and Computer Science though I have little practice in competitive programming. Let me know if there is any way to convince Google team to make me qualify for Round 2 quoting the conflict result between Judge and interactive tool. -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/ba75479c-9e31-429b-b7c7-59bd7f010598%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[gcj] Re: Code Jam 2019 Round 1C Power Arrangers problem gives me WA. Please help.
It seems instead of printf/scanf, If I use cout/cin, in the above program it is getting accepted. Initially, I submitted c++ based cout/cin only. But since I didn't include newline character endl, It was giving TLE. I thought it was something to do with cin/cout. So, I changed to printf/scanf. Then It started to gave WA. After the competition time is over, I just added endl at the end of every cout and it got accepted. Because C program didn't get accepted, I spent almost addtional 1.5 hrs to fix which by that time competition was over. I couldn't start 1st problem. Can someone guide me if there is any problem with printf & scanf of C language dealing with characters? Because in my case cout/cin works but printf/scanf does not work. -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/3d83a5da-48d7-4a1f-83ac-147bfa3b97bd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[gcj] Re: Code Jam 2019 Round 1C Power Arrangers problem gives me WA. Please help.
I found a mistake in the code. It should be ram[(i+4)/5][1]=ch; instead of ram[(i+5)/5][1]=ch; But, even after correcting it, It gives Wrong Answer only. Please help. Also, let me know how can I test the solution with the python interactive tool provided in the problem statement. I wrote this code in less than 45 minutes time but It took me a lot time to figure out where the mistake is. Also, It cost me the entire contest time and denied the opportunity to compete in Round 2. -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/1a988a77-9448-4ed6-a798-1fe0814f60b4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[gcj] Code Jam 2019 Round 1C Power Arrangers problem gives me WA. Please help.
Hi, In Round 1C for Power Arrangers problem, Below is my solution. But, It gave Wrong Answer. I could not find any fault. Since, this is interactive problem, I could not test in IDE. Please help. #include using namespace std; int main() { //ios_base::sync_with_stdio(0); //cin.tie(NULL); //cout.tie(NULL); int tt, n; cin>>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; char ch; rA=rB=rC=rD=rE=0; for(int i=1;i<=595;i=i+5) { //cout<>ch; scanf("%c",); ram[(i+5)/5][1]=ch; if(ch == 'A') rA++; else if(ch == 'B') rB++; else if(ch == 'C') rC++; else if(ch == 'D') rD++; else if(ch == '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",); ram[i][2]=ch; if(ch == 'A') rA++; else if(ch == 'B') rB++; else if(ch == 'C') rC++; else if(ch == 'D') rD++; else if(ch=='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; //cin>>ch; printf("%d\n",(i-1)*5+3); fflush(stdout); scanf("%c",); ram[i][3]=ch; if(ch == 'A') rA++; else if(ch == 'B') rB++; else if(ch == 'C') rC++; else if(ch == 'D') rD++; else if(ch == '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); scanf("%c",); ram[i][4]=ch; if(ch == 'A') rA++; else if(ch == 'B') rB++; else if(ch == 'C') rC++; else if(ch == 'D') rD++; else if(ch == '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<>verdict; scanf("%c",); 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/3ead7ac7-64b2-4054-a898-3b5cf9fdb83b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [gcj] Question about Code Jam 2019 Round 1B second problem - Draupnir
On Tuesday, April 30, 2019 at 11:19:29 PM UTC+5:30, DahliaSR wrote: > Hello, > > > >> "But, for example after 68 days, it will contribute R1*2^5 rings to the > >> total rings, right?" > > > That's wrong! It still does contribute 0. > The number of R1 contributes 0 total for ANY day larger then 62. > Why is that? : > Day 63: R1 * 2^63 ≡ 0 (mod 2^63) 2^63 is a multiple of 2^63 so the > remainder MUST be 0 > Day 64: R1 * 2^64 ≡ 0 (mod 2^63) 2^63 is a multiple of 2^63 so the > remainder MUST be 0 > R1 * 2^(63 + 1) ≡ 0 (mod 2^63) 2^64 is less than 2^63 > and therefore a multiple 2^63 so the remainder STILL MUST be 0. > > > So when querying day 324, you can ONLY identify R(6) at day 0. > > > Am Di., 30. Apr. 2019 um 17:35 Uhr schrieb Ramesh Kumar : > On Tuesday, April 30, 2019 at 8:18:56 PM UTC+5:30, /dev/joe wrote: > > > The 1-day rings duplicate every day, so their contribution to the sum moves > > one bit left in the binary representation every day. After 63 days, since > > we only get the value mod 2^63, the 1-day rings make no contribution to the > > value you get. > > > > > > > > > On Tue, Apr 30, 2019 at 10:05 AM Ramesh Kumar wrote: > > > Hi All, > > > > > > > > > > > > It was mentioned we can use two chances for Code Jam 2019 Round 1B second > > problem - Draupnir. But I think we can use only one number 324 which is > > sufficient and find the solution. But, I am unable to get the accepted > > answer. Is there anything wrong to use only 324 number to find all the > > required six numbers? Please help me to understand. > > > > > > > > > > > > -- > > > > > > 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 googl...@googlegroups.com. > > > > > > To post to this group, send email to googl...@googlegroups.com. > > > > > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/google-code/10442015-c57d-4edd-9ac4-dce29cd20eb2%40googlegroups.com. > > > > > > For more options, visit https://groups.google.com/d/optout. > > > > But, for example after 68 days, it will contribute R1*2^5 rings to the total > rings, right? > > > > -- > > 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 googl...@googlegroups.com. > > To post to this group, send email to googl...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/c27fe3f0-935e-4ce9-bdcf-b3f31fb422f9%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. Thank you all for the explanation. Now I understood what was my mistake which cost me the qualification to Round 2. I had little confusion in calculating modulo. Now I am clear. One last chance I have in Round 1C. I have to wait and see if I can clear the round. -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/bac7360a-619e-40e5-81fc-f5e1cd29d9aa%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [gcj] Question about Code Jam 2019 Round 1B second problem - Draupnir
On Tuesday, April 30, 2019 at 8:18:56 PM UTC+5:30, /dev/joe wrote: > The 1-day rings duplicate every day, so their contribution to the sum moves > one bit left in the binary representation every day. After 63 days, since we > only get the value mod 2^63, the 1-day rings make no contribution to the > value you get. > > > On Tue, Apr 30, 2019 at 10:05 AM Ramesh Kumar wrote: > Hi All, > > > > It was mentioned we can use two chances for Code Jam 2019 Round 1B second > problem - Draupnir. But I think we can use only one number 324 which is > sufficient and find the solution. But, I am unable to get the accepted > answer. Is there anything wrong to use only 324 number to find all the > required six numbers? Please help me to understand. > > > > -- > > 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 googl...@googlegroups.com. > > To post to this group, send email to googl...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/10442015-c57d-4edd-9ac4-dce29cd20eb2%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. But, for example after 68 days, it will contribute R1*2^5 rings to the total rings, right? -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/c27fe3f0-935e-4ce9-bdcf-b3f31fb422f9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[gcj] Question about Code Jam 2019 Round 1B second problem - Draupnir
Hi All, It was mentioned we can use two chances for Code Jam 2019 Round 1B second problem - Draupnir. But I think we can use only one number 324 which is sufficient and find the solution. But, I am unable to get the accepted answer. Is there anything wrong to use only 324 number to find all the required six numbers? Please help me to understand. -- 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 google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/10442015-c57d-4edd-9ac4-dce29cd20eb2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.