c++ - A. Appleman and Easy Task -


http://codeforces.com/contest/462/problem/a problem , want solve c++ can 1 explain me want here specially @ line of question

and answer can`t understand https://github.com/ahmedalbarbary/competitive-programming/blob/master/codeforces%20-%20not%20mine%20codes/problem-%20462a%20-%20appleman%20and%20easy%20task

thanks helping me

you have count every cell [i,j]
  how many of cell [i,j-1], cell[i,j+1], cell[i-1,j], cell[i+1,j] (i.e. adjacent cells, i.e. neighbour cells) contain 'o'.

if count number (for every cell [i,j]) result "yes", else "no". (thus, test may finished when first odd count detected.) thereby, 0 counted number (of course).

the possible issue:

for border cells, of tests have skipped prevent out-of-bound access.

the solution uses trick this: stores input beginning indices [1,1] instead of indices [0,0]. leaves "unused" border cells around actual input matrix. advance: no tests cells skip necessary.

as memory filled '*' before unused border cells not have negative effect counting.

why trick used:

the platform perform read access border cells , counting faster check (for every cell) whether cells have skipped (to prevent out-of-bound access).


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -