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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -