Hello problem solvers!
I'm glad to invite you to participate in HackerEarth September Easy Challenge. it will start on September , 1st at 16:00 UTC, link of the contest: September Easy Challenge
There will be 6 algorithmic problems of varying difficulties (from easy to medium) and you will be given 3 hours to solve them, each problem is worth 100 points and partial points is allowed (you will be given points of each test case you pass). Top 5 beginners will receive HackerEarth T-shirts.
Problems are set by subway, Tested by Me kingofnumbers and the editorialist is ikbal
we did our best to prepare the contest so we hope you enjoy it and benefit from it.
looking forward to see you on the contest , Good luck!
Is the contest individual or team participation ?
it is individual contest.
Is there penalty for time?
Yes, ties are broken by time penalty
Is the number of tests the same for all problems?
I don't think that it is necessary.
Congratulations to the winners! https://www.hackerearth.com/september-easy-15/hof/ Also, the editorials are out. :)
I was trying the last problem from the contest -- here
my documented solution here I would be glad if someone can look into the solution and figure out the anomaly in it. Thanks.
You are calling function dfs(i, j) from top left to right down which is very wrong. Instead call it in the increasing order of cell values i.e. from (i, j) such that a[i][j] = 1 to (k, l) such that a[k][l] = 100.
I thought over what you suggested but I still can't figure out how positions of launching dfs will affect the result. it would be great if you could give a small counter test case , that would make things clear ,and thanks for your time.
Error is in your dfs function inside the loop, in the nested if statement it should be:
if(!vis[x+adj[0][i]][y+adj[1][i]])
instead of:
if(!vis[x+adj[0][i]][x+adj[0][i]])
And use long long for storing ans, just to be safe.
Here is the working code
thanks a lot shubham for taking out the time and looking into the code. btw pathetic mistake on my part :(.
Oh, by the way, if anyone is interested in setting / testing, or writing editorials for the future Easy contests, they can drop me a message.