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

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

I get this when i submit code —

but when i run my exact same testcase in test against custom input window i get —

which is the correct output.

here is my submission — Submission

what am i doing wrong?

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

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

Maybe it is occurring because of the global stuff you have declared . Not resetting them for each test case would lead to problems.

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

    I tried clearing global variables but now it gives TLE :< Submission

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

      Make things local, pass things by reference in your helper functions.

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

        ok , but i don't find anything wrong in declaring it global and clearing it for testcases , why would it anyway lead to TLE , but declaring it each time locally would pass?

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

          I have not went through your code, but see suppose you have

          vector<int>graph[N]
          

          , as graph adjacency list representation of graph and N is of 1e5 order. You have made it global.

          Clearing it whole for each case till N may give you TLE.

          But if you clear it till your required input n, then it may not give TLE.

          I have faced TLE lot of time because of clearing everytime time for whole graph.

          So either clear till n(given input size) or make it local and pass it by reference in required helper functions.

          Sorry I havent seen your code, I will see it later.

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

don't get it

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

not got any reason