I was solving Total Diamonds problem from Dec long challenge Here is the link to my submission. My solution is getting passed for sub task 1 but I am getting WA in subtask 2, and TLE in 3. Anyone please help me to figure out what why I am getting WA.
The reason of WA in second subtask is integer overflow.
Here is the corrected (only for WA) version of your code. (Only changed data type from int to long).
For 100 points, you need to optimize your approach.
Try to exploit the fact that upper and lower triangles are similar for any N * N grid. And also observe that last column of N*N grid is somewhat being repeated in the (N+1) * (N+1) grid. Try to implement these two facts in your code.
Here is my solution for 100 points.