rachitiitr's blog

By rachitiitr, history, 8 years ago, In English

Problem: http://codeforces.com/contest/677/problem/B
The user is doing rem = a[i];
while(rem) {if (rem >= k) rem -= k; }
See the image for his code:
http://codeforces.com/predownloaded/0a/2d/0a2d8f1ff5bca1d364d6224513611c725c9a0df2.png
If I set k = 1, and rem = 10^9 Clearly it will timeout, but I was given an unsuccessful hacking attempt. Why?

Test case I gave:
1 1000000000 1
1000000000
Result-> Unsuccessful

I thought compiler would be doing some optimizations. So turned k to 2. Still it gave unsuccessful hacking attempt. IInd Test case I gave:
1 1000000000 2
1000000000
Result-> Unsuccessful

UPD -> His code got TLE after the final system checks. -_- http://codeforces.com/contest/677/submission/18191327

This is a great way to suffer a loss of 200 points.

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

»
8 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Obvious answer — fast servers ( > 1e9 cycles per sec). There have been many posts/comments regarding this.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Even if you would have given the value of n around 10-15 instead of 1 with big a[i]'s, your hack might be successful.

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Might be due to Fast CF server. Code runs on this test case in 624ms when I tried it in CUSTOM INVOCATION.

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by rachitiitr (previous revision, new revision, compare).

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

1e9 simple operations = ~1 second.

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

On servers 10^9 fast operations go for ~0.6 seconds While 2*10^9 operations took around 1.2 seconds You should have provided test case as: 2 1000000000 1 1000000000 1000000000 To get a successful hacking attempt

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks everybody for letting me know this. It was otherwise indigestible.