yassin_'s blog

By yassin_, history, 6 years ago, In English

This is about 845B - Luba And The Ticket from educational round 27.

My code got AC for C++14 34715622 and TLE for C++11 34715609. Can anyone tell me why? Diagnostics also TLEs, so I couldn't use that to check for undefined behaviour.

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

»
6 years ago, # |
  Vote: I like it +24 Vote: I do not like it

I think culprit is slow to_string().

I resubmitted your code as 34719330 with string x(to_string(i)) call replaced by

char buff[20];
sprintf(buff, "%d", i);
string x(buff);

under C++11 5.1.0, and it works in ~170 ms.

Presumably implementation of to_string() was slow in version 5.1.0 of compiler and improved at some version <= 6.4.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

this is irrelevant but which version of CLion are you using for Jhelper. Did you buy one?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    2017.2 you can get it for free with a university email address