Tle in one of the cases

Can you please tell me that in which case tle is coming and how to resolve it.

your code is giving wrong answer for n=11 , your code output is tle correct output is 2680
use optimzesolution
if Queen is placed in particular row then change row value