Codevita2019

Yes i have solved aprox 12-13 different problems.

The links of the separate rank lists of zone1 & zone2 are
Zone 1 : Zone1
Zone 2 : Zone 2
Source : https://campuscommune.tcs.com/channels/codevita-season-8

Anyone who got the mail regarding invitation for a Direct Interview for a
career with TCS.

I have got an email for Call Basis Interview

anyone have taken screenshot of problem statement workbalance of tcs codevita if so please do share it or anyone remember it…pls share

Could you pls provide me the ā€˜life guard’ solution. I was getting runtime error ,but public test cases were passed!

//solved using binary search to prevent time exceed error you can use brute force also

#include <iostream>

#include <cmath>

using namespace std;

long double xl, yl, xw, yw, f;

long double calculate_it(long double i)

{

return sqrt(((xl - i) * (xl - i)) + (yl * yl)) / f + sqrt((xw - i) * (xw - i) + yw * yw);

}

long double search_it(long double start, long double end)

{

long double mid, current, prev, next;

long double ans = -1;

while (true)

{

    mid = (start + end) / 2;

    prev = calculate_it(mid - 0.000001);

    current = calculate_it(mid);

    next = calculate_it(mid + 0.000001);

    if (prev > current && next > current)

    {

        ans = mid;

        break;

    }

    else if (prev > current)

    {

        start = mid + 0.000001;

    }

    else

    {

        end = mid - 0.000001;

    }

}

return ans;

}

int main()

{

cin >> xl >> yl >> xw >> yw >> f;

long double count;

if (xl > xw)

{

    count = search_it(xw, xl);

}

else

{

    count = search_it(xl, xw);

}

printf("%.6lf", (double)count);

return 0;

}

/*

Explanation

(time)

 ^    

 |     *                            * 

 |       *                       *  

 |          *                 *

 |              *          *  

 |                    *           <--------(x_min )

 |

(0,0)±-------------------------------------->(position)

       |                          |

     (x_l)                      (x_w)

       

       |___________________________|

       (x_min is between this point)    

we can use binary search by using the following condition :

  1. start = min(x_l,x_w) , end = min(x_l,x_w)

  2. calculate middle = (start + end )/2

  3. find the time taken for position (middle-0.000001) , (middle) ,(middle + 0.000001) by using the formula ;

  4. let the calucated time be prev, current and next respectively.

we can find direct our binary search using following condition ;

if( time taken in middle position is smaller than both prev and next )

then this is the required position 

else if( time taken in middle position is >time taken n prev postion )

 then move right  

else

move left

*/

(time_min)