DottedCalculator's blog

By DottedCalculator, history, 12 months ago, In English

In the recent div 3 and div 4 rounds, I keep getting hacked.

  • Vote: I like it
  • +12
  • Vote: I do not like it

»
12 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Avoid python.

If you must use python, use fast input and output using sys.stdin.readline and sys.stdout.write (or print only one result at the end).

Consider how your code works on the largest possible input case.

If your solution is taking close to the time limit, try to resubmit so that even if one solution gets hacked, the more efficient solution stays (definitely do this after solving all problems).

»
12 months ago, # |
Rev. 3   Vote: I like it +33 Vote: I do not like it

Submitting your recent hacked solution adding in

import sys 
input = sys.stdin.readline

ACs in 326ms/2000 ms.

In problems with many testcases, calling print $$$T$$$ times, can be very slow, so it can be much faster to store all $$$T$$$ answers in an array out and call

print('\n'.join(map(str, out)))

once at the end of your programs.

»
12 months ago, # |
  Vote: I like it -16 Vote: I do not like it
The only possible way that guarantees that you will avoid being hacked
»
11 months ago, # |
Rev. 2   Vote: I like it +13 Vote: I do not like it

It happened again, this time in C++ :(

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You can use the following code to speed up cin and cout.

    code
  • »
    »
    11 months ago, # ^ |
      Vote: I like it +30 Vote: I do not like it

    How ? I see you solved the 8 questions and global rank 4

»
11 months ago, # |
  Vote: I like it +19 Vote: I do not like it

Now, you've hacked the editorialist's solution itself.