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

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

Today I completed my second competition (#333) and an important question regarding time limits arose. I solved the B problem in O(n) time and after locking the problem, I saw that a participant in my room solved it in O(n^2) time. Consequently, I wanted to hack his solution based on the given time limit, but I wasn't sure if my challenge would succeed.

So my question is how do you generally estimate if your/someone else's solution would fit the time constraint? I am aware that constants get dropped in big-O, but I am looking for some general rules. For this example, the aforementioned user would perform at least n*(n+1)/2 operations in worst case with n being at most 100 000 and time limit of 2 seconds. Was it reasonable to attempt to hack his solution and what is your approach with regard to the time limit?

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

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

I just ran a few tests and found that the CF judging servers can do 2.45 * 10 ** 9 integer operations + updates and 1.225 * 10 ** 9 integer comparisons in 1 second (with GNU C++11).

Just multiply the number of operations in a loop by the amount of times it loops and try to estimate using that. You might also want to test the speed of vector and other STL data structures.

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

This handy table will answer all of your questions. (Reference: Competitive Programming 3)

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

Here is my answer to a similar question. I typically use 4·108 operations per second as a rule of thumb.