Ny0n's blog

By Ny0n, 11 months ago, In English

My submission 243855915 for 1925A exited with the code 13131312 on test case 2. I couldn't find any details online on this specific code. Any idea what might be causing this?

  • Vote: I like it
  • +7
  • Vote: I do not like it

»
11 months ago, # |
  Vote: I like it +13 Vote: I do not like it

Do this

string res = s;
FOR(i,n-1)res+=s;
cout<<res<<ln;

as for why s += s is not working. use the input 4 4 you'll see what is going wrong and somewhat like 26 26 will give the runtime

  • »
    »
    11 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Oh Thanks!

    My bad, should've noticed the problem with s+=s.

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

Looks like this exceeds some internal limit on the output size (~50 megabytes?) before anything else.

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Indeed, I get bad_alloc when I run it with 26 26 in my local ide.

    Still, I'm kinda curious about the error code which was generated.

    • »
      »
      »
      11 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      This code occurs when some of the judge's internal limit is hit.

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

while you run s+=s it will increase your initial set of character exponential time, for example, 3,4:-Initial s="abcd' then s+=s gives s='abcdabcd' i.e., two times of original s, again after s+=s gives s='abcdabcdabcdabcd' i.e., 4 times of the original s but we need only 3 times of original s. so, use temporary_var=s for the first time and then, loop for (i, n) s+=temporary_var. if you use python you can do this in one line s=s*n or s*=n. I hope you understand the error.