DESTCELL - Editorial

https://www.codechef.com/viewsolution/26210572
solved in nmlog(n*m) still getting tle in 1 subtask.
Can anyone tell why.

Using map, makes your actual complexity :- NM.log(n.m).log(n.m)
Remove maps.

1 Like

Thanx!!:slightly_smiling_face:

1 Like

Okay I will try to do it now. Thank you for looking into my code.

Can someone pls tell me why I’m getting a RE?

Check the output of your program after addding the debugging code at line 35.

https://ideone.com/FN282S

Your program is incorrectly changing the row index i and the column index j.

The following is a slight update to your program which fixes the row index and column index problems, and correctly destroys and counts the destroyed cells in the grid.

https://www.codechef.com/viewsolution/26239446

Check the previous post.

@taran_1407 - thanks for the Editorial! Can you please remove the superfluous “L” from the thread Title? It’s really bugging me XD

“DESTCELLL - Editorial” :slight_smile:

Edit:

Phew - that’s better :slight_smile:

Edit2:

May as well post my solution - it’s a little slow (but not TLE, of course :)), but readable, I hope :slight_smile: CodeChef: Practical coding for everyone

Understood. Thanks a lot

Now that you pointed it out, I cant unsee it and its unnerving AF. Edited out, thanks!

2 Likes

Phew, that’s better - thanks!

Although I apparently earned “Regular” a couple of hours ago, so it turns out I could have done it myself XD

2 Likes

Damn, that’s really unnerving. Don’t know how i missed it first time. Thanks for edit @vijju123

2 Likes

showing TLE error in one of the subtask. what’s wrong?

https://www.codechef.com/viewsolution/26316696

hello, can you tell me what’s wrong with this solution?
showing TLE for the last case.

https://www.codechef.com/viewsolution/26325132

Congratulations! :smile:

1 Like

Hehe - thanks :slight_smile: I’ve already wielded my new, Almighty Power by fixing the spelling in this thread title XD : Very large array declaration

Soon no one on Earth will dare challenge me …

3 Likes

Lol! That’s awesome! :smile:

1 Like

The following is a slight update to you code using C++ STL vectors.

https://www.codechef.com/viewsolution/26696953

You may check if changing the data type of the coordinates to “int” insteat of using
“long long” as well as adding “cout.tie(nullptr)” at the beginning of the main function can get your code accepted. If not, the reason may be the overhead in initializing hero1 and hero2 using the overloaded assignment operator.

you are creating new bitset variable vu inside loop every time. creating a bitset varible has complexity of o(n). so time complexity of your code is 10^6nm which is nearly upto 10^12 and hence you are getting TLE.

Actually the time limit is strict.I also did the same for the first time.
The points are:
1)Instead of creating a mesh ,just assume that its present and store and check visited points using set or map(But you may still get TLE, as I got :stuck_out_tongue:)
2)Also, converting 2D to 1D would be helpful.
( ind(1D)={(ind/m)+1,(ind%m)+1}in 2D)

The overall time complexity of our code is the same but the constants increases, i.e. the smaller complexities which we ignore (like n*m is smaller compared to nm log(nm)), resulting in TLE.