amit5148's blog

By amit5148, 14 years ago, In English
Problem A
Iterate over all possible pairs of soldiers and count those having difference of their heights less than or equal to d.

Problem B
Replace all occurrences of '--' with '2', '-.' with '1' and '.' with '0'.
Initially, there was some problem with the test cases but was rectified soon.

Problem C
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.

Problem D
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)
if(StarAt(x,y,radius))
k--;
if(k==0)
//display start at x,y,radius
else
//display -1

Problem E
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 :)

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it