codechef april cook-off is a disaster

It was really a disaster, I have just solved a single problem, but that one too I submitted it lately. I have submitted it with in 13 minutes and 45 seconds, by that time 180 members have already made a positive submission. and second question I took was Travelling with chef, which is very time taking yet easy question. I don’t even understand why my code is giving wrong answer,

I wrote the code for calculating the quotients of the polynomial with Cramer’s rule of matrices, and after finding the quotients I went to integrate the velocity polynomial to get the distance at a specified time, and then as the question states that chef has started at time 0, I have assumed the integrating constant to be zero. and after printed the result. But it is giving me a wrong answer, I don’t understand it at all.

believe me you shouldn’t go to the question page. I was literally frightened when I saw code of a solution.

But the good news is that my ratings for short contest have increased by 262 points.

Screenshot from 2014-04-21 00:36:10


here’s my code

#include <stdio.h>
#include <math.h>
double determinant(double *q,double *w,double *e,double *r);
int main()
double T3[4],T2[4],T1[4],P[4],X[4],ultimatetime,det,A[4]={1};
int i,j,testcases;
scanf("%lf", &ultimatetime);
for (i = 0; i < 4; i++)
scanf("%lf%lf", &T1[i], &X[i]);
for (i = 0; i < 4; ++i)
printf("%lf\n", ((P[0]*pow(ultimatetime,4))/4.0)+(P[1]*pow(ultimatetime,3)/3.0)+(P[2]*pow(ultimatetime,2)/2.0)+(P[3]*ultimatetime));
return 0;
double determinant(double *q,double *w,double *e,double *r)
return (*q)*(*w+1)*(*e+2)*(*r+3)-(*q)*(*w+1)*(*e+3)*(*r+2)-(*q)*(*e+1)*(*w+2)*(*r+3)+(*q)*(*e+1)*(*w+3)*(*r+2)+(*q)*(*r+1)*(*w+2)*(*e+3)-(*q)*(*r+1)*(*w+3)*(*e+2)-(*q)*(*q+1)*(*e+2)*(*r+3)+(*q)*(*q+1)*(*e+3)*(*r+2)+(*q)*(*e+1)*(*q+2)*(*r+3)-(*q)*(*e+1)*(*q+3)*(*r+2)-(*q)*(*r+1)*(*q+2)*(*e+3)+(*q)*(*r+1)*(*q+3)*(*e+2)+(*e)*(*q+1)*(*w+2)*(*r+3)-(*e)*(*q+1)*(*w+3)*(*r+2)-(*e)*(*w+1)*(*q+2)*(*r+3)+(*e)*(*w+1)*(*q+3)*(*r+2)+(*e)*(*r+1)*(*q+2)*(*w+3)-(*e)*(*r+1)*(*q+3)*(*w+2)-(*q)*(*w+1)*(*r+2)*(*e+3)+(*q)*(*w+1)*(*r+3)*(*e+2)+(*q)*(*r+1)*(*w+2)*(*e+3)-(*q)*(*r+1)*(*w+3)*(*e+2)-(*q)*(*e+1)*(*w+2)*(*r+3)+(*q)*(*e+1)*(*w+3)*(*r+2);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s