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

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

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.

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

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

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 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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