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

Автор Logical_Operator, история, 3 года назад, По-английски

Today, during the contest, the problem 1546/B showed all pretests passed(4 pretests). Later it failed the system test and showed TLE on testcase-4 (but pretest-4 was initially passed during contest). I again submitted the exact same code a while ago, and now got accepted. I can't really understand what's going on...

Contest time code- https://codeforces.com/contest/1546/submission/122111498

The same code I ran after contest- https://codeforces.com/contest/1546/submission/122141000

See, both the codes are exactly same.

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

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

The question is how?

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

this is a similar solution which gets tle 122133864 But testcases for B are weak, this slightly modified solution gets accepted in 46ms 122134450

[Edit]: ans=ans+char('a'+j); is slow(O(n) maybe) i replaced it with cout<<char('a'+j); (31ms) 122142595

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

A tip, use array/vector for storing the frequency of alphabets, instead of a map, this is a proof that an extra $$$log$$$ factor can bring such a change.