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

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

the problem is http://codeforces.com/contest/513/problem/C

the solution is http://codeforces.com/contest/513/submission/9761274

i wonder how this solution not TLE it is 1009*1009*6*6*6 which is TLE

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

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

Dude. You don't just analyze the complexity by counting for loops

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

    the each iteration in the for loop work as i clear the dp array so this is the complexity i am confused :s

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

      For clearing the dp array, I see four for loops and they go till 6,6,6,10009 so how TLE?

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

        no i mean the dp is in 10009*6*6*6 okay but there is for loop iterating on dp in the main so what is the total complexity ?

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

          Memoization technique has been used in the solution, which means you just calculate the value for each state only once. Therefore the whole solution proceeds 10009*6*6*6 different states which is pretty far from TLE.