problem with implementing this question of codechef

Pages: 1... 7891011... 13
closed account (zU7LhbRD)
@dMonkey

congo bro , you figured it out
its the new account
@dffloy please see what I am doing wrong.
And I am a new user just created account after seeing the discussion.
Any help would be appreciated
closed account (zU7LhbRD)
@shikkari

give me the output for these inputs

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
@ defloy

2
1.83825
0.531013

outputs.
It is passing only single case in code chef but a given test case in cpluscplus by @ffloyd site it passes all test case. someone please find the bug in it.


#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector< long long int> vi;
vi subtract(vi a,vi b){
vi ans;
for(int i=0;i<3;++i){
ans.push_back(a[i]-b[i]);

}
return ans;
}
lli dot(vi a,vi b){
lli ans=0;
for(int i=0;i<3;++i){
ans+=a[i]*b[i];
}
return ans;
}
vi input(){
lli x;
vi a;
for(int i=0;i<3;i++){
cin>>x;
a.push_back(x);
}
return a;


}
int main(){
lli test;
cin>>test;
while(test){
vi p,q,d,c;
lli r;
lli cons1,cons2,cons3,cons4,cons5,cons6;
vi cp,qp;
p=input();
q=input();
d=input();
c=input();
cin>>r;



cp=subtract(c,p);
qp=subtract(q,p);

cons1=dot(cp,cp);
cons2=dot(cp,qp);
cons3=dot(cp,d);
cons4=dot(qp,qp);
cons5=dot(qp,d);
cons6=dot(d,d);

long double X,Y,Z;

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));




long double t,t1,t2;

if(X==0){
t=(-1*Z)/Y;
cout<<setprecision(7)<<t<<endl;
}
else{
t1=((-1*Y)+sqrt(Y*Y-(4*X*Z)))/(2*X);
t2=((-1*Y)-sqrt(Y*Y-(4*X*Z)))/(2*X);

if(t1>=0 && t2<0)cout<<setprecision(7)<<t1<<endl;
else if(t1<0 && t2>=0)cout<<setprecision(7)<<t2<<endl;
else if(t1>=0 && t2>=0)cout<<setprecision(7)<<min(t1,t2)<<endl;
}


--test;
}
return 0;
}
@texasgirl123 see above post and find bug in it.

@shikhari

Thanks for pointing out my error


u just set precision 12 in ur code..........

@all

those who r getting their case accepted for 1st case but wrong for other cases just increase ur precision value upto 12..... u will got AC..................


U got mess just with precision value....
@ghostrideriit did you get your subtask 2 AC
@texagirl123 lol ok
whats the latest issue..i am here to help close this thread?
@ tapilu
can you provide any idea on how to solve this question-
https://www.codechef.com/JUNE18B/problems/TWOFL
Last edited on
or is there anyone who have solved any of these-
Two Flowers - TWOFL

Ways to Work - WRKWAYS

Expected Buildings - BUILDIT
please give idea .
even partial solution will work but please give idea.
Last edited on
......
Last edited on
yes.
See the message box @keve @tapilu
Last edited on
anyone has TWOFL or WRKWAYS or BUILTIT code.
pls send
yes anyone with these questions TWOFL or WRKWAYS or BUILTIT

please share the idea , how to do it , if they can not share the code.

@lastchance please help with these questions.
Last edited on
@mythio thanks bro.finally got it,it was a very simple mistake.


1 0 AC
(0.000000)
1 1 AC
(0.680000)
1 2 AC
(0.710000)
Subtask Score: 25.00% Result - AC
2 3 AC
(0.770000)
2 4 AC
(0.740000)
2 5 AC
(0.760000)
2 6 AC
(0.720000)
Subtask Score: 75.00% Result - AC
ak 2614 can some help me pleese ,me too got lost in 1st test cse pass and rest WA:(
Pages: 1... 7891011... 13