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

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

what is the problem in this code to get tle?? https://codeforces.com/contest/1389/submission/102948197

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

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

Although your code is a little hard for me to read, a quick skim shows that you are checking the value of vis[idx][left][flag] but it doesn't seem that you ever set it. This would render your DP useless since you never use the values you memoize.

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

    maybe, end of main, "visid++" resolve that problem

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

      Since vis is declared globally, its value will always be zero. However visid starts at 1, and is only changed at the end of main. Honestly I don't see any reason for that increment to be there at all since by that time the answer has already been printed. But it definitely shouldn't changing the behavior of the program that is executed before that statement.

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

        Oh, I was mistaken for something. Now I understand. thank you

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

    yes thanks alot i just put vis[idx][left][flag]=visid; and i got it ac