problem with implementing this question of codechef

Pages: 1... 678910... 13
closed account (4iEqDjzh)
@ffloyd It's still WA:

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


Man, this is depressing...I want to sleep so bad rn :/
Last edited on
closed account (43hf216C)
anyone who wants VISION, BINARYSHUFFLE or NAIVECHEF full AC code can contact me (PM) if you give me one of these:
sheokand (trie implementation)
twoflower
waystowork
or
buildit
cheers!
Last edited on
@dMonkey
its so frustating right now for me too , when i'll got back my PM i'll contact to you
@dMonkey
i cann't share my code here, wait for PM link, we have to find it out anyhow , you got it almost
can anyone shere the result for test case (those who did it)
for test case 1:
1
1 1 1 -1 -1 -1 1 1 1 0 0 0 .2
test case 2:
1
5 5 5 -5 -5 -5 1 2 3 0 0 0 2
test case 3:
1
5 5 5 -5 -5 -5 1 2 3 -1 -2 -3 2
test case 4:

1
5 10 15 -5 -15 -25 1 -2 6 -2 -1 -3 2

please anyone who did it right.
i just want to check for my code.
Last edited on
..
Last edited on
@ipg 2016069

2.000000
1.838248
0.531013
nan
respectively

@ffloyd Thanks. Got the all AC. 100%. i big thanks for you.
thanks for your help @Wasp and @lastchance and others
Those who struggling can use this for output cout<<fixed<<setprecision(6)<<T<<"\n";
Last edited on
closed account (DGLCfSEw)
@ffloyd only last test case is giving wrong output in my code
PM me when you see this
Last edited on
@ffloyd thanks
and @ipg 2016069
thanks for pointing out the error

finally got 100.0

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%
closed account (DGLCfSEw)
SO finally after banging my head for more than 5 days now, I got full AC...It was depressing even at one point I left the problem and started doing TWOFL(Got 20 in it so..:P)

A big big thanks to @ffloyd dude you are a legend.
@lastchance thanks for clearing my conecpts, @Wasp thank you for raising the right questions @ipg for giving the best test cases and everybody else in this thread.

Have fun guys. cheers and as a parting gift I'll show you the dankest shit you'll ever see: https://www.youtube.com/watch?v=DJfg39WkMvE enjoy XD !!

@monkeyD

your a,b,c co-efficients values were correct?????????
closed account (4iEqDjzh)
@ghostrideriit Yes, they were, I was messing up my output, read the past comments, you'll surely get it
1
2
3
4
5
6
7
8
9
10
11
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));


@flloyd, are you sure that these constant values are correct? I was using similar values, but I am not getting past the given test case. Can it be a problem with my output?
for god sake tell me the issue plz xD
this is irritating now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>

#include<iostream>
#include<math.h>
#define DB long double 
using namespace std;

DB dot_product_result(DB x1,DB y1, DB z1, DB x2, DB y2, DB z2)
{

    DB result1= x1*x2+y1*y2+z1*z2;

     return result1;

}

int main()
{
  DB t,p1,p2,p3,q1,q2,q3,d1,d2,d3,c1,c2,c3,r;
  cin>>t;
  while(t--)
  {     

     cin>>p1>>p2>>p3>>q1>>q2>>q3>>d1>>d2>>d3>>c1>>c2>>c3>>r;
  DB constant1= dot_product_result(q1-p1,q2-p2,q3-p3,q1-p1,q2-p2,q3-p3 );
  DB constant2= 2*dot_product_result( q1-p1,q2-p2,q3-p3,d1,d2,d3);
  DB constant3= dot_product_result(d1,d2,d3,d1,d2,d3);

  DB constant1_1= dot_product_result(q1-p1,q2-p2,q3-p3,c1-p1,c2-p2,c3-p3);
  DB constant2_2= dot_product_result(d1,d2,d3,c1-p1,c2-p2,c3-p3);

  DB term1= dot_product_result(c1-p1,c2-p2,c3-p3,c1-p1,c2-p2,c3-p3);

  DB a= r*r*constant3- term1*constant3+ constant2_2*constant2_2;
  DB b= r*r*constant2-term1*constant2+ 2*constant1_1*constant2_2;
  DB c= r*r*constant1- term1*constant1+constant1_1*constant1_1;

   if(a==0.0)
       cout<<fixed<<setprecision(6)<<-c/b<<endl;
   else {   
      
   DB time1,time2,t;
    DB a = (-b/(2*a))/(2*a);
    DB b = (sqrt(b*b-4*a*a))/(2*a);
 
    time1 = a+b;
    time2 = a-b;

      if (time1<0)
               cout<<fixed<<setprecision(6)<<time2<<endl;
      else if(time2<0)
                 cout<<fixed<<setprecision(6)<<time1<<endl;
      else if(time1>=0 && time2>=0)
                 cout<<fixed<<setprecision(6)<<min(time1,time2)<<endl;
  }

  }


}



god bless.
@MonkeyD


I m using same co-efficients as u but still wrong output...

i m using this for output..........


double t1 = (-b+ sqrt((b * b) - (4 * a * c))) / (2 * a);
double t2 = (-b - sqrt((b * b) - (4 * a * c)) / (2 * a);
if (t1 > t2) {
cout << setprecision(6)<<t1 << endl;
} else {
cout << setprecision(6)<<t2 << endl;
}
}
@ ghost
please make sure you take care of corner cases too.
refer my code on top.

@all
please help out guys...
@yousuckloljk, what's the output of these test cases?

1
2
3
4
5
4
1 1 1 -1 -1 -1 1 1 1 0 0 0 .2
5 5 5 -5 -5 -5 1 2 3 0 0 0 2
5 5 5 -5 -5 -5 1 2 3 -1 -2 -3 2
5 10 15 -5 -15 -25 1 -2 6 -2 -1 -3 2
@ iHavenoname
strangely it prints nothing o_o
i don't get it x_x
Thanks all for the discussion I got it:)
Last edited on
Pages: 1... 678910... 13