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

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

Today I am doing 1107G, I find there is something wrong with my st-table, so I change the st-table into brute force and submit it only to check if my main algorithm is correct.

But to my surprise, the brute force got an "Accepted" verdict in "233ms".(the time limit is 3.5s) https://codeforces.net/contest/1107/submission/180935577

I am very confused and check the time complexity of my code.

Then I find that:

The st-table code is $$$O(n\log n)$$$.

If I change the <= on the 61-th line into <,it's also right though it seems to be $$$O(n^2)$$$. Because under the constraint of $$$d_{i}<d_{i+1}$$$, it's impossible to construct a testcase with more than 40000 positions with a increasing $$$(d_{i}-d_{i+1})^2$$$.(if the limit of $$$d_i$$$ is $$$10^{18}$$$,it will be TLE as well.

But the original code is totally wrong. It will be TLE on a test constructed in this way:

int cur=100;
cout<<300000<<" "<<300000<<endl;
cout<<1<<" "<<100000<<endl;
rp(i,299999)cout<<cur+i<<" "<<1<<endl;

It takes around 25s for the original code to run, much more than 3.5s.

The Custom Invocation of Codeforces can input only 255KB test, so I test it on another OJ (luogu). You can take a look at https://www.luogu.com.cn/problem/U261730 and submit #180935577 into it to see if it has a correct complexity.

And all the correct codes runs well on the only Hacking data.

I know Codeforces has very good testing computer, but it can't change 25s into 3.5s.(If it can...)

I don't know what to do to hack or add testcases to a 5-year-ago edu contest.

I also don't know how many people got "Accepted" in this problem with totally wrong code.(maybe only me?)

If there's some ways to submit hacks or add testcases, please tell me.

If it is unnessesary in Codeforces rules, please ignore this blog or tell me under the blog.

And please tolerate my poor English :)

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

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

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

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

I think this is not valueable just like you.

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

I won't tell you the three unrated guys above me are all the same people's Alt-account, he is just in a same classroom with me.

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

The comment is hidden because of too negative feedback, click here to view it

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

UPD: After apply some constant optimization to the wrong code, it easily become one of the best solutions submitted to 1107G. It is so funny that a solution with a complexity of $$$O(n^2)$$$ spends only 62ms to pass a problem with $$$n=300000$$$.