problem with implementing this question of codechef

Pages: 1... 45678... 13
@ipg your math is too week i suggest you to go through this

http://www.qc.edu.hk/math/Advanced%20Level/Point_to_line.htm

i got 100 pts by using one of those formulas

Sub-Task Task # Result
(time)
1 0 AC
(0.000000)
1 1 AC
(0.370000)
1 2 AC
(0.350000)
Subtask Score: 25.00% Result - AC
2 3 AC
(0.420000)
2 4 AC
(0.380000)
2 5 AC
(0.410000)
2 6 AC
(0.350000)
Subtask Score: 75.00% Result - AC
Total Score = 100.00%
ohh @MonkeyD just removed his para,
@ texasgirl123, here it is
cons1=scalarproduct of (c-p,c-p)
cons2=scalarproduct of (c-p,Q0-p)
cons3=scalarproduct of (c-p,d)
cons4=scalarproduct of (Q0-p,Q0-p)
cons5=scalarproduct of (Q0-p,d)
cons6=scalarproduct of (d,d)


X=(r*r*cons6-(cons1)*(cons6)+(cons3)*(cons3));
Y=2*(r*r*(cons5)-(cons5)*(cons1)+(cons2)*(cons3));
Z=(r*r*cons4-(cons1)*(cons4)+(cons2)*(cons2));

X*t^2 + Y*t + Z=0

you can find out very easily, it is almost ,give it to try
Last edited on
hey @wasp
please share your code
closed account (DGLCfSEw)
@ffloyd or @Wasp
can you please point out what I am missing in output statements?
@keve i cannot share my code here as it may lead to plagiarism.

@MonkeyD how can one pick a mistake from the formula that is not derived ?
closed account (DGLCfSEw)
@Wasp , I shared the coefficients earlier, @ffloyd is confirming those are correct, but I am not handling output correctly.
Can you please just help me in output part?
@ wasp
i will not copy the code
i will surely change the full code so it will not lead to plagiarism.

as if i will copy paste the code then my ranking will also goes down , so don't worry i will definitely change the whole code so that it will not lead to plagiarism

please share.
@MonkeyD
i just saw your output values the above you pasted here
T1=(-B+sqrt(B*B-4*A*C))/2*A;

here in execution first the numerator divided by 2 and then all that shitty stuff multiplied by A
it should be first T1=(-B+sqrt(B*B-4*A*C))/(2*A);
first correct it ,even it creates problem then we will go for it
Last edited on
closed account (DGLCfSEw)
@ffloyd thank you for pointing that out, still getting WA tho.

Is there still something missing?
I feel like such a dumbass rn, I can't even think now...:(
Last edited on
Got AC. thanks @ffloyd you actually pointed out my error :D
Sub-Task Task # Result
(time)
1 0 AC
(0.020000)
1 1 AC
(1.340000)
1 2 AC
(1.320000)
Subtask Score: 25.00% Result - AC
2 3 AC
(1.360000)
2 4 AC
(1.340000)
2 5 AC
(1.360000)
2 6 AC
(1.290000)
Subtask Score: 75.00% Result - AC
Total Score = 100.00%
Last edited on
friends please some one please share your working code.

you can make changes in your code , and it will not lead to plagiarism
as after your changes i will also make changes in the code.

so don't worry it will definitely not lead to plagiarism.

please share it.
closed account (DGLCfSEw)
@codexhammer is the coefficients that @ffloyd pasted up there , correct right??
closed account (DGLCfSEw)
@ffloyd can you tell me what else I am missing, please.
@MonkeyD I don't know man. I broke the points into coordinates. It took 5 minutes extra but removed all the discrepancies of dot and cross product rules. Just follow this formula :
r^2 = ((Q(t)-p)x(P-C))^2 / (Q(t)-P)^2
Break the points in their respective coordinates and follow the approach that @lastchance told to separate t-terms from the equation. And don't forget to put brackets according to BODMAS rule while giving the output which was what i was doing wrong! :)
@texasgirl I would insist you try once more with the above approach. Changing variables to avoid plagarism won't help much :(

PS : Compute the constants stepwise and not in one go to avoid mistakes.
Last edited on
@codexhammer , any time ;)

@MonkeyD:
give me the coefficient else match with my coefficient which was i pasted above
the coefficients which was i pasted gave me AC in all the test cases
Last edited on
closed account (DGLCfSEw)
@ffloyd My coefficients are exactly equal to yours, am still getting wa.
If you could open your PM, i could send you my code for review? or If something is wrong in this you could point out:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
long double T,T1,T2;
        if(A==0)
        {
            T=-C/B;
            cout<<T<<"\n";
        }
        else
        {
           T1=(-B+(sqrt(B*B-(4*A*C))))/(2*A);
            T2=(-B-(sqrt(B*B-(4*A*C))))/(2*A);

            if(T1<0){cout<<T2<<"\n";}
            else if(T2<0){cout<<T1<<"\n";}
            else if(T1>=0 && T2>=0)
                {
                    if(T1<T2)
                        cout<<T1<<"\n";
                    else
                        cout<<T2<<"\n";
                }
        }


Please guide me.
Last edited on
Did anyone get all AC(I am getting TLE on 70 marks subtask) on Sheokhand and String?
I got partially 30 points correct!.
Can someone explain me how can I remove the TLE?Any efficient approach?
Thanks.
@ffloyd
Last edited on
@the1marvellous It's a different thread. But just use tries and take an array of indices[] in the node structure. That array will contain the indices of the strings in which the character at the node appeared. Then find all the strings which has LCP with P and check which of those strings' index lie in the range(1,R).
closed account (43hf216C)
@codexhammer can you give link to that thread
@MonkeyD Your ouput code is exactly same as mine :-/ not sure about the coefficient part but this is 100% correct. Just to confirm this is my code in Python:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
if A==0:
        t = -1*C/B
        print(t)
    else:
        t1 = (-1*B + (B**2 - 4*A*C)**0.5)/(2*A)
        t2 = (-1*B - (B**2 - 4*A*C)**0.5)/(2*A)
        t=0
        if t1<0:
            t=t2
        elif t2<0:
            t=t1
        elif t1>=0 and t2>=0:
            t=min(t1,t2)
        print(t)  


@texasgirl123 http://www.cplusplus.com/forum/beginner/237882/
Last edited on
Pages: 1... 45678... 13