Funky_chessboard

here is the link to my code


i dont know where i am doing the mistake,can u help me .

bro the entire code is commented which part do i debug

i have commented all the three codes…try whichever part u want

check this code
this is a backtracking + recursion code

first version of my code is also recursion +backtracking why it it giving tle…?can u check…

please tell the significane of
arr[x][y].first=1; and
arr[x][y].second=1;

also please share a bit of ur approach for the first code…
like it is 70% clear

here is the link for the code… https://ide.codingblocks.com/s/255009 i have updated it and mentioned my approach at every step in the comments and i have also answered your query …please check

just a small update was required


pass the vector <vector<pair<int,int>>> arr by reference and the code works fine

what was causing the error when i was not passing it by reference. was it the time taken in making the copy of the vector…i guess…

update permanent nhi h to isliye TLE araha tha

i did not understood the reason for tle…can u please explain it a bit briefly…

see we were passing vector<vector> by value hence updates were not permanent

and lead to continuous update in each call without prior knowledge of update that had happened in previous steps

by using reference operator
the updates made to the board were permanent hence each subsequent step made a move with prior knowledge of updated board

ok ,thank u …now i understood it.

1 Like