Hi. I finally solved problem F from ABC 180 but my happiness was short-lived because it took $$$7s$$$ for my program to run on the worst case ($$$N=300$$$ $$$M=300$$$, $$$L=300$$$) in Custom Invocation.
Here is the link to my submission.
I have proven that the time complexity of my solution is $$$O(NMLlog(L))$$$, and also maintained a variable
tick (see line $$$83$$$ and line $$$184$$$) which shows the number of loop operations and in the worst case, $$$tick=76279724$$$, which is not even $$$10^8$$$.
I have tried to optimise my code in every way possible, but I can't bring it below $$$7$$$. Is my code doomed to fail because of the costly
mod, or am I missing something?
You don't need to solve the problem to help me because I have maintained the variable
tick and it is clearly less than $$$10^8$$$.
Any help would be appreciated! My code is quite short and neat :P