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

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

Regarding Div3 D problem submission 1 submission 2 Here both the solution are same but the fact is one is hacked and other is not ,could u please suggest the input User Id link

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

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

You don't need to worry. After the hacking stage is over, all solutions from all participants will be tested against all extra testcases discovered by hackers. If the second submission is still buggy, it will be rejected too.

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

    bro i asking about reason why so??

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

      The changes indeed seem to be just cosmetic:

               // db(x);
               if(x < 0){
      -            dp[abs(x)][1]++;
      -            ans += dp[abs(x)][1]-1;
      +            int r = -x;
      +            dp[r][1]++;
      +            ans += dp[r][1]-1;
               }
      

      But both are slow and very close to TLE. I suspect that memset of the dp array is killing performance. If t is very large, then the whole buffer gets cleared way too many times.

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

        Bro it got accepted in final testing

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

          It got accepted after completing the 11th testcase in 1981 ms, which was only 19 ms away from failing (the time limit is 2 seconds). With some minor runtime speed fluctuations, it could either get accepted or fail.

          What's your problem? Do you want to know why this solution takes almost 2 seconds? Or did you want it to get a TLE verdict very much?

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

Server load presumably the difference. Really, they both ought to fail — it's bad code. It is not good to do memset on dp[200005][2] for each of 10000 test cases — that's 4 billion operations.