Iterate over all possible pairs of soldiers and count those having difference of their heights less than or equal to d.
Replace all occurrences of '--' with '2', '-.' with '1' and '.' with '0'.
Initially, there was some problem with the test cases but was rectified soon.
I won't be discussing my approach to this problem as my solution was hacked :( and I haven't tried another approach yet.
Earlier I thought that my code failed because I was using int for storing answer,but later found that its giving WA after changing it to long.
Simple approach was to start finding stars in order of their indexes.
For this, first try for stars with smaller radius, then for top and finally for left.
Following code may explain it further.
int radius, x, y;
for(radius=1; k>0 && radius<=150;++radius)
for(x=radius; k>0 && x < N-r;++x)
for(y=radius; k>0 && y < N-r;++y)
//display start at x,y,radius
Haven't yet solved this problem too. Will be updating soon.
This was my second contest at Codeforces. I was able to solve more problems this time and enter div 1, so enjoyed it :)