Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

perfectionist7's blog

By perfectionist7, 2 months ago, In English

So, when I put in the language to be GNU G++20, the program shows testcase failed at testcase 27 which is

3 1 2 2 2 3

It shows I become the guy in the Participant's output section but when I run the exact same code in my VS Code, it shows the output as Oh, my keyboard! which is the same as the jury's answer. I can't really understand whats wrong.

My code —

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by perfectionist7 (previous revision, new revision, compare).

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by perfectionist7 (previous revision, new revision, compare).

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

See the problem is when you write arr3[i] = arr[i] in the range (a+b), in the for loop.Though you wrote the if condition, firstly in the program this line "arr3[i] = arr[i]", will be compiled and then it will move to the if block which gives seg fault. replace the content in the forloop with: if(i>a-1) { arr3[i] = arr2[i-a]; } else{ arr3[i] = arr[i]; } and it will get accepted.