quest. is confusing...
but see that we can compress each road into a line and thus no. of rectangles will be pq...
how is the ans. gven this?
compressing roads into lines each gaps bcom rectangles formed and also each chowk bcom intersection point of lines....
shortest possible routes..
watever u do u will have to cover the boder line much dist. at min....
do it in rectangle lik a chess board...go through edges anyway frm one end to other
progress frm one end say bottom left most... cornor... going along line (compreesed roads) go either up or right and reach other cornor.. cant go down and left... as shortest..( all will yield same dist.. include thm all usin perm. comb.)
hope this helps
Cheers!!!!!!!
my b diagram ud help...
watever happens u will hve to cover "p" dist. horizont. and q dist vertically to reach other corner..
so u can go up in q-1 ways and rit in p-1 ways .... no other direction can u go as least dist.