Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

Блог пользователя Ny0n

Автор Ny0n, 6 месяцев назад, По-английски

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?

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

»
6 месяцев назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

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

»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    6 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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.

»
5 часов назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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.