### amit5148's blog

By amit5148, 11 years ago, 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 :)  32, Comments (6)
 » Have you solved problem E by now?:-)
 » Is there a way to solve the problem A without using nested loops?
•  » » #include using namespace std; #define FOR(i,n) for(int i=0;i<(n);i++) int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); string s,r; cin >> s; int n{ 0 }, i{ 0 }; n = s.size(); for(i=0;i
•  » » » Yeah, this is a correct solution for 32B. :) Though I was wondering if there is any O(n) solution for 32A.I mean without using any nested loop or something like that.
•  » » » 12 months ago, # ^ | ← Rev. 3 →   #include using namespace std; #define ll long long #define f(i,s,n) for(ll i=s;i>s; f(i,0,s.ln){ if(s[i]=='.'){ cout<<0; continue; } if(s[i]=='-'&&s[i+1]=='.'){ cout<<1; i++; continue; } if(s[i]=='-'&&s[i+1]=='-'){ cout<<2; i++; } }`}
 » Rest in peace problem E