Can anybody help on why I am getting runtime error on this? I almost followed the editorial and it passed the sample test cases + my weak(simple) test cases. https://www.codechef.com/viewsolution/34616966
A test case with answer where the code shows runtime error is all I need! Thanks in advance.
My code gave TLE in PyPy 3. I tried to optimize a lot to get AC. Finally after frustration, I submitted the same code in Python 3 and it gave AC. Now After the contest the same code is giving AC in both PyPy 3 and Python 3. Waiting for rating drop.
as per the constraints, N>=1, M>=1 and u[i] != v[i]
So for n=1,there can’t be any edge but still we need to add one as per the constraints(bcoz M>=1). @taran_1407 can you please clarify this or is this a typing error ?
Hi akshitm, same here brother. I tried DFS recursive (with setrecursionlimit to 10**6). Then I tried DFS iterative in the contest… Both gave TLE using pypy
I tried many other optimizations. But still got TLE. This is infuriating. If the problem cannot be solved using pypy/python in given constraints…they should mention it.
My code gave AC in Python after many attempts in PyPy. So, your statement the problem cannot be solved using pypy/python in given constraints is false.
I implemented the same thing using BFS, but have only inserted those vertexes to the adjacency list whose percapita is equal to the maximum percapita.
This got TLE. https://www.codechef.com/viewsolution/34621844
You are using floating point arithmetic. At some point there can be precision loss. Use an integer data type to compare. See setters code or my submission.
ALWAYS AVOID FLOATING POINT ARITHMETIC IF IT’S POSSIBLE!
I am sure python/pypy solution gave TLE during contest. Please either regrade or remove that question from ranking list. I tried optimizing my code for it. It always gave TLE. If the problem cannot be solved in a specific language for given constraints then why can’t you clearly mention it?
Two of my submission attempts: https://www.codechef.com/viewsolution/34623632 CodeChef: Practical coding for everyone (Accepted after contest) But clearly not within the 1 second constraint. I am sure this can’t go from 3.87 to 1 second …I have tried dfs recursive/iterative/stdin input …every possible optimization I could think of.
So back to my main point. You could have clearly stated this problem constraints was only for optimized C++. And don’t both wasting time trying to do it in python. Rating is going to fall now