It gives the wrong answer for this testcase:
1 28 PAAAPPPAAPPAPPPAAPAAAPAPAAPP
You edited the title since I posted However, the linked submission:
is WA, not TLE.
i am getting output 7 … is it wrong . plz check this is my new code…
7 is correct, but your original code gave
Your submission https://www.codechef.com/viewsolution/30705864 gives a TLE, and the wrong answer for this testcase:
1 8 AAAAPAAP
for that my output is coming 4… what should be the answer and how to remove TLE?
Write faster code Your solution looks like it’s O(T \times D^2), and with D=1000 and T=200, this is going to be fairly tight in C++, and probably not possible with Python (the amount of time taken by a Python solution is immensely variable).
A O(T \times D) solution is possible, so aim for that.
OK but i think the answer 4 is right as we can hit proxies on the two A’s between the two P’s and the 2 A’s left of the Left P.
No, we can’t - please read the rules carefully
The only day he can be marked as present by proxy is day 6:
is badly worded - it means he cannot be marked as present-by-proxy on any of the following days: day 1; day 2; day D-1; day D. Although I guess this is kind of implicit, anyway