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

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

Hello Codeforces, I have been working on the problem 1176E - Cover it! and submitted the following code: 248930264 (I submitted many but I felt this one was the closest to go through) My time complexity was the standard O(N + M) N vertices M edges but couldnt get the code through however I found a similar code 248919921 which got Accepted with the same time complexity and simmilar constant factors What is the difference between the codes / why did my code tle?

thank you in advance litvinas

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

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

Write bool vis[n + 1] & bool mark[n + 1] instead of 2e5

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

    That worked,Thank you

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

    Nice. Can you explain how does it impact that please?

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

      Hii , as far as I understand declaring array of size 2e5 [which means running a loop of size 2e5] for each input would result us in performing > 1e7 operations for large number of testcases [i.e. t] where the values of n & m are small [for them to be within constraint limit] , hence by using bool vis[n + 1] & bool mark[n + 1] we use the fact that ∑m≤2⋅105