The Way to a Friends House Is Never Too LongProblem code: POINTS |
All submissions for this problem are available.
You are given a set of points in the 2D plane. You start at the point with the least X and greatest Y value, and end at the point with the greatest X and least Y value. The rule for movement is that you can not move to a point with a lesser X value as compared to the X value of the point you are on. Also for points having the same X value, you need to visit the point with the greatest Y value before visiting the next point with the same X value. So, if there are 2 points: (0,4 and 4,0) we would start with (0,4) - i.e. least X takes precedence over greatest Y. You need to visit every point in the plane.
Input
You will be given an integer t(1<=t<=20) representing the number of test cases. A new line follows; after which the t test cases are given. Each test case starts with a blank line followed by an integer n(2<=n<=100000), which represents the number of points to follow. This is followed by a new line. Then follow the n points, each being a pair of integers separated by a single space; followed by a new line. The X and Y coordinates of each point will be between 0 and 10000 both inclusive.
Output
For each test case, print the total distance traveled by you from start to finish; keeping in mind the rules mentioned above, correct to 2 decimal places. The result for each test case must be on a new line.
Example
Input: 3 2 0 0 0 1 3 0 0 1 1 2 2 4 0 0 1 10 1 5 2 2 Output: 1.00 2.83 18.21 For the third test case above, the following is the path you must take: 0,0 -> 1,10 1,10 -> 1,5 1,5 -> 2,2 = 18.21
| Date: | 2008-12-01 |
| Time limit: | 6s |
| Source limit: | 50000 |
| Languages: | C C99 strict C++ PAS gpc PAS fpc JAVA JAR C# C#2 ASM D FORT ADA BASH PERL PYTH RUBY PHP LISP sbcl LISP clisp HASK CAML |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

java.util.comparator interface helps here lot ... i don't have to implement any sorting algorithm
sort() works just fine in C
C (cpp) that is - why did my double ' ' get stripped?
The debugger is stating the answer comes out to be correct.
But here on submitting it says wrong answer. Unable to understand what is wrong.
In order to optimize i tried using float, but the thing works with double.
@pratik vakil float has lesser precision than double.
there is a number format exception that is thrown on one of the 'test case' integers. i had to wrap the parsing of the 'test case' individually to get a successful run. i guess i should be wrapping them all in try-catch clauses individually anyway. i've gotten lazy...still, it is strange that the test data has an error in it. especially since the format instructions were very specific.
stuck!
unable to generate a test case for which my submission will fail :(
admin or moderator.... plz provide some hint.
Try some more :)
suppose the total distance is 1.256
What should be the output? 1.25 or 1.26?
1.26.
sorry for the last post.... it should be 1.26 ....evident frm the second sample test case..... i m giving up.... i have tried for all the test cases i can think of.... and none of them fail :(
how can I round upto 2 decimal points?
double t = 45.493847;
int x = t*100;
t = x / 100.0;
printf("%.2lf", t);
Something like this?
this is my
this is my code :
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
char c;int n,i,*x,*y,j,t,k,z;
float s;
cin >> t;
for ( z = 0 ; z < t ; z++ )
{
i = 0;k=0;
cin >> n;
x = new int[n+1];
y = new int[n+1];
for ( i = 0 ; i < n ; i++ )
cin >> x[i] >> y[i] ;
s=0;
for( j = 0 ; j < n - 1 ; j++ )
s = s + sqrt ( pow((y[j+1]-y[j]),2) + pow((x[j+1]-x[j]),2) );
printf("%.2fn", s);
delete []x;
delete []y;
}
}
can anyone tell the error?its showing wrong answer.
You don't seem to be obeying
You don't seem to be obeying any of the rules mentioned in the problem. Try reading it again.
Hi Admin I've completed and
Hi Admin
I've completed and successfully run the code for this problem and it works fine for many test cases with me..It runs fine and exactly as per the problem constraints on my laptop.
Java version on my laptop:
___________________________
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
I'm using Ubuntu:9.04
Could you pls tell me if I can personally send you my src file, So that you can compile and run it, & let me know if I'm making some critical mistake as per Directi program evaluation norms..
:)
u know how it makes feel, when it's all correct and still it appears not.
Well, if you are getting a
Well, if you are getting a wrong answer, then your code is not correct and is producing the wrong result for some of the test cases. :)
Dear Admin, I am getting
Dear Admin,
I am getting TLE everytime. My answers seems to be correct. I have tried using merge sort then again insertion sort but all times I am getting TLE? Can u provide any hint what sorting algo to apply??
it keeps saying run time
it keeps saying run time error i think its the array size of 10000 which i am using giveing the problem, admin can you tell if i am coreect.
@anupam i would say try using
You are trying to create a
What will be the answer for a
I mean (0,0), (0,2), (0,4),
@Ravi Looks like you solved
@Ravi
Looks like you solved it... mind answering your own question for us? I had the same question; I think the problem needs to be worded more clearly. When read literally, I think it would produce 28 for your problem, but I don't understand the motivation for designing the problem that way unless it is solely to try and confuse people about the rules.
@fortress you are right, the
@fortress 8.00 is the correct
if input is
if input is (1,10),(2,19),(1,6),(2,20),(1,8),(1,18). wat ll be visiting order...? is this correct (1,10),(1,8),(1,6),(2,20),(2,19),(1,18)..?
You have to start with
You have to start with (1,18). Read the problem statement carefully.
can I declare a 2-D array
can I declare a 2-D array "int xy[RANGE][RANGE]" for each test case?
I generate input and seems to work fine on my laptop but chef gives runtime error.
No, 10000*10000 ints is about
No, 10000*10000 ints is about 380mb which is far too much memory.
<!-- @page { margin:
<!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } -->
Hi,
I have defined a number of reasonably small test cases to run and all succeeded. I then set up a test case generator to comply with codechef specifications. The number of tests are user defined at the command line but all other parameters are generated by random number selection conforming with the directions set forth. The output from this program becomes the input for the POINTS program. Randomly selecting x number of tests within the test file and solving those by hand, I could insure the answers are correct. They were. I am still, after 5 runs getting a runtime error of NZEC. Since I am using Python the types of errors to produce this result are finite. I think they possibly reflect an error on one of the test cases.
I would like to know if some error was built into the test cases. If this is correct, I think you have violated your own standards. What I have always liked best about CodeChef is the directions for each problem are exceedingly well defined. We know the inputs and we know exactly what criteria govern their creation. Therefore, if an error has been deliberately introduced this is a violation of your standards and should certainly not be used under the assumption that a 'good programmer' knows to code for invalid data. That is true but in a controlled environment such as codechef or SPOJ this is an invalidated exercise and either the test data should be recreated and firmly tested or the problem should be dropped.
Again, if I am in error, I apologize for my rant and would like to submit to you both my solution and my test deck because suddenly this has become a most unusual and perplexing situation.
Thank you,
Robert
The problem has been solved
The problem has been solved by 133 people, and there is nothing wrong with the input. If you are getting a runtime error then something is wrong with your solution, rather than codechef 'violating their standards'.
I'm storing the sum in a long
I'm storing the sum in a long double, so I'm loathe to think that I'm losing precision there. Still, I'm coming up with WA. What a puzzle.
I've solved the problem, but
I've solved the problem, but it is giving me wrong answer. It might be some case that i'm omitting some of the test cases. Can anybody suggest me any test case. Some important one which can exhaustively be applicable for the whole problem.
Thanks in advance...!!!
Here's a testcase generator
Here's a testcase generator that might help. It helped me find a bug in my program. Good luck!
#!/usr/bin/python
import sys, random
testcases, points = 20, 100000
print testcases
for i in range(testcases):
print ''
print points
for point in xrange(points):
print random.randint(0, 10000), random.randint(0, 10000)
oops, sorry, bad formatting,
oops, sorry, bad formatting, here goes again:
For those who are having
For those who are having problems and are getting Wrong Answer, are you compiling in Windows? I was, and I got 3 Wrong Answers on this even though all my program seemed to be correct. Compile on Linux (I use Ubuntu) and it might show you whats wrong with your program, at least it did for me.
I am getting Runtime Error
I am getting Runtime Error while submitting my Java code. The error code as sent in the email to me is NZEC. From http://www.codechef.com/wiki/status-codes#Q._Why_do_I_get_an_error_calle... link, I came to know that it can be because of some unhandled exception thrown by a Java program.
I have tried testing my program with boundary conditions on my own. I am unable to somehow crash my program. Can I get the exception class??? or any kind of hint???
ok i got the issue.... just a
ok i got the issue.... just a case to take into consideration.... there can be same set of points more than once in the input :)
I'm using the Comparable
I'm using the Comparable interface in java to sort my points. However, my result turns out to be Time limit exceeded...I was wondering if anyone had successfully used this approach or whether I should try another more efficient sorting algorithm, because I see no other way of optimizing my program.
Scanners are very very very
Scanners are very very very slow. Never use them.
Hi everybody, In my C
Hi everybody,
In my C program, I am using math.h for sqrt. So when i am compiling it in my system, I need to give use the following command , "gcc -lm test.c" , only then the program runs. However when I am submitting here, I am getting "wrong answer". Is it because I am using math.h, that I am getting the "wrong answer". If so, what do yo suggest me to use for sqrt function?
Regards,
Vignesh
No, your code is not giving a
No, your code is not giving a compiler error. Wrong answer means you are printing out the wrong thing, which means there is a test case that you are giving the wrong answer for. Not that the sqrt function isn't working.
i don't understand the
i don't understand the problem for last case why can't i go directly to 2,2 from 0,0 ... the problem statement says only u can't go to a point having less value of X ... so i guess i can go anywhere except that???
oops didnt read last line :)
oops didnt read last line :)
missed return statement in
missed return statement in main...!!! and wasted time..
where do i get more
where do i get more information on this
i checked with the above test
i checked with the above test cases , program is running fine and also tested it on sample test cases genterated by the python script given above (for sorting). still i am getting wrong answer :( , any hints ?? or some corner cases that i may be missing
You may have another bug, but
You may have another bug, but floats aren't very precise; they are only accurate to about 7dp. Adding 100000 of them will leave your answer only accurate to about 1dp; you should really always be using doubles for accuracy.
got it , was using float
got it , was using float instead of double :(
http://www.codechef.com/views
http://www.codechef.com/viewsolution/243257
plz provide some hint at where i m goin wrong.i m getting runtime error
thanks
i am getting time limit
Will the input consist of all
Will the input consist of all of the points sorted, or if i need to sort them in my solution, i would have to do it explicily?
The problem statement doesn't
The problem statement doesn't say anything about the order the points can appear in, so you shouldn't assume anything.
Could anybody help me out: I
Could anybody help me out:
I am getting a runtime error(other), and despite reading the FAQ, I am unable to figure out where I am going wrong.
Link to my code is:
http://www.codechef.com/viewsolution/280103
It has been bugging me. Would be really grateful if someone could help.
Have you tried a test case
Have you tried a test case with 100000 points?
Have you read the section called 'Other common mistakes' in the FAQ?
(The answer to both is no ;))
@Stephen: I did try out my
@Stephen: I did try out my code on a test case generator of 100000 points. Seemed to work fine. Can you please help a little more?
As mentioned in the FAQ, a
As mentioned in the FAQ, a new line is \r\n, which you aren't handling properly.
I may have been mistaken on the first point, let me look again.
@stephen: Oh no, I am reading
@stephen: Oh no, I am reading 30000 characters at a time. I guess my problem is with the newline character. I am fixing it.
@stephen: any suggestion as
@stephen: any suggestion as to how to handle rn ?
I meant how to handle the
I meant how to handle the newline character?
can anyone tell me what's the
can anyone tell me what's the problem here...it's giving wrong answer!!! but i couldn't find any problem... please help.
#include<stdio.h>
#include<math.h>
long x[100010],y[100010];
long i,j,k,t,n,p,q,r,temp1,temp2;
double sum;
int main(){
//freopen("input.txt","r",stdin);
scanf("%ld",&t);
for(p=0; p<t; p++){
scanf("%ld",&n);
for(q=0; q<n; q++){
scanf("%ld",&x[q]);
scanf("%ld",&y[q]);
}
for(i=0; i<n; i++){
for(j=i; j<n; j++){
if(x[i]>y[j]){
temp1 = x[i];
x[i] = x[j];
x[j] = temp1;
temp2 = y[i];
y[i] = y[j];
y[j] = temp2;
}
else if(x[i] == y[j]){
temp1 = y[i];
y[i] = y[j];
y[j] = temp1;
temp2 = x[i];
x[i] = x[j];
x[j] = temp2;
}
}
sum = 0;
for(i=0; i<n-1; i++){
sum = sum + sqrt(pow((double(x[i+1])-double(x[i])),2) + pow((double(y[i+1])-double(y[i])),2));
}
}
printf("%.2lfn",sum);
}
return 0;
}
i have no other choices but
i have no other choices but to post my code.plz have a look....i have tried lots of test cases...but my answer is incorrect..plz help
#include<stdio.h>
#include<math.h>
#define p 100001
long long int a[p][2],u=-1,v=-1,n;
void quicksort(long long int,long long int);
int main()
{
int t,i;
long long int j,p1,q,r,s1,k;
double s;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
k=0;
s=0.0;
scanf("%lld",&n);
for(j=0;j<n-k;)
{
scanf("%lld",&r);
scanf("%lld",&s1);
if((r!=0)||(s1!=0))
{
a[j][0]=r;
a[j][1]=s1;
j=j+1;
}
else if((r==0)&&(s1==0))
{
u=r;
v=s1;
k=k+1;
}
}
n=n-k;
quicksort(0,n-1);
for(j=0;j<(n-1);j=j+1)
{
p1=a[j][0]-a[j+1][0];
q=a[j][1]-a[j+1][1];
s=s+sqrt(pow(p1,2)+pow(q,2));
}
if((u==0)&&(v==0))
s=s+sqrt(pow(a[0][0],2)+pow(a[0][1],2));
printf("%.2fn",s);
}
return(0);
}
void quicksort(long long int left,long long int right)
{
long long int pivot,i,j;
long long int temp;
if(left<right)
{
i=left;
j=right+1;
pivot=a[left][0];
do
{
do
{
i=i+1;
}while(a[i][0]<pivot);
do
{
j=j-1;
}while(a[j][0]>pivot);
if(i<j)
{
temp=a[i][0];
a[i][0]=a[j][0];
a[j][0]=temp;
temp=a[i][1];
a[i][1]=a[j][1];
a[j][1]=temp;
}
}while(i<j);
temp=a[left][0];
a[left][0]=a[j][0];
a[j][0]=temp;
temp=a[left][1];
a[left][1]=a[j][1];
a[j][1]=temp;
quicksort(left,j-1);
quicksort(j+1,right);
}
for(j=0;j<right;j++)
{
if(a[j][0]==a[j+1][0])
{
if(a[j][1]<a[j+1][1])
{
temp=a[j][1];
a[j][1]=a[j+1][1];
a[j+1][1]=temp;
}
}
}
}
frnds can anybody help me out
frnds can anybody help me out on this problem
its clearly written that
You start at the point with the least X and greatest Y value, and end at the point with the greatest X and least Y value.
and for the last case the anser turns out to be the following order
(0,10)->(1,5)->(1,2)->(2,0)
for wich the answer turns out to be
10.33
hi i have used mergesort for
hi
i have used mergesort for sorting and i am TLE.
@people who hav submitted code...
which algo u used for sorting??
i used quicksort too..
i used quicksort too..
guys is blank line and new
guys is blank line and new line is same i mean n tell me :D
:( Internal Error Occured in
:( Internal Error Occured in the system...
Do any1 know why this error comes up???
Hi, can we have 3 values of Y
Hi, can we have 3 values of Y for same value of X
Points can be anywhere they
Points can be anywhere they want.
well guys i have done my code
well guys i have done my code quite simply & shortly using struct...everythings are ok except the time limit! m damn dead for knowing what the problem really is...please help somebody!here goes my code:
#include<stdio.h>
#include<math.h>
typedef struct
{
int x;
int y;
}point;
point points[10000];
void sort(int n)
{
int temp;
for(int i=(n-1);i>=1;i--)
{
for(int j=0;j<=(i-1);j++)
{
if(points[j].x>points[j+1].x)
{
temp=points[j].x;
points[j].x=points[j+1].x;
points[j+1].x=temp;
temp=points[j].y;
points[j].y=points[j+1].y;
points[j+1].y=temp;
}
else if(points[j].x==points[j+1].x)
{
if(points[j].y<points[j+1].y)
{
temp=points[j].y;
points[j].y=points[j+1].y;
points[j+1].y=temp;
}
}
}
}
}
void countDistance(int n)
{
double result=0.0;
for(int i=0;i<(n-1);i++)
{
result+=sqrt((points[i+1].x-points[i].x)*(points[i+1].x-points[i].x)+(points[i+1].y-points[i].y)*(points[i+1].y-points[i].y));
}
printf("%.2fn",result);
}
int main()
{
int test,iterator;
scanf("%d",&test);
for(int i=0;i<test;i++)
{
scanf("%d",&iterator);
for(int j=0;j<iterator;j++)
{
scanf("%d %d",&points[j].x,&points[j].y);
}
sort(iterator);
countDistance(iterator);
}
return 0;
}
oh...my struct point is
oh...my struct point is something like point[100000]...either it shows runtime error!
but what making its to be so time consuming?
Your sort uses a nested loop,
Your sort uses a nested loop, and therefore takes around 100000*100000 iterations. That doesn't have a hope of running quickly. There are much faster sorting methods.
thanks i understood it after
thanks i understood it after i had closed my pc in Anger! hehehe :P
hi friends i tried few
hi friends
i tried few submitted solutions, and i guess everyone is missing this condition: for points having the same X value, you need to visit the point with the greatest Y value before visiting the next point with the same X value.
because for the following test case
4
0 0
0 2
0 4
0 8
output should be
(0,8)-->(0,4)
(0,4)-->(0,8)
(0,8)-->(0,2)
(0,2)-->(0,8)
(0,8)-->(0,0)
the answer should be: 28
but the programs i tried from the submission are giving the answer: 8
as it is clearly written in the question that if u are visit a point with the same value of x, we have to visit the point with maximum y. i think by visiting to that point we have to add distance from current point to that point. and then from point with maximum y to the next point.
admin if i m wrong please correct me
hi friendsi tried few
hi friends
i tried few problems from the submission and found that they all are not obeying this condition: for points having the same X value, you need to visit the point with the greatest Y value before visiting the next point with the same X value.
if we obey this condition for the following test case
4
0 0
0 2
0 4
0 8
output should be: 28
Explanation:
(0,8)-->(0,4)
(0,4)-->(0,8) *
(0,8)-->(0,2)
(0,2)-->(0,8) *
(0,8)-->(0,0)
but if we do not follow this condition:
(0,8)-->(0,4)
(0,4)-->(0,2)
(0,2)-->(0,0)
output: 8
as it is clearly mentioned that if we have to visit any point with same x we have to visit the point with maximum y. in explanation the visit marked with * are the same visits.
admin please correct me if i m wrong.
The problem is written in
The problem is written in pretty poor english; taken literally you are correct. The problems intends you to visit points (where x is the same) from the highest y value down to the lowest value.
Stephen: ya you are correct.
Stephen: ya you are correct. later i also realised that for coordinates with same we just have to take minimum and max value of y and leave the coordinates in b/w
thanx anyway
I kept getting wrong answer
I kept getting wrong answer until i changed the way I formatted my output. I still don't know what's wrong with my original output method can someone help?
originally i had this
The toString() method of
The toString() method of Double will show any value which is at least 10^7 (possible here with the right input) in exponential notation, which is what is causing the wrong answer.
The simplest correct code doesn't involve any DecimalFormat class at all:
System.out.printf("%.2f\n",distance);ah thanks for the
ah thanks for the explanation. I realized i could just go with
System.out.printf("%.2fn",distance);
right after i pressed save on the previous comment
To Stephen: When I upload my
To Stephen:
When I upload my program, it goes on running without showing any message. What do you think, what should have gone wrong??
To Stephen: When I upload my
To Stephen:
When I upload my program, it goes on running without showing any message. What do you think, what should have gone wrong??
To Admin: When I upload my
To Admin:
When I upload my program, it goes on running and running without showing any message. What do you think should have gone wrong??
BUUUUUUUUUUUZZZZZZZZZZZZZZZZZ
BUUUUUUUUUUUZZZZZZZZZZZZZZZZZZZZZ!!!!!!!!!!!!!!
Is there anyone to answer my query????
Hello everyone... Iam Aafreen
Hello everyone...
Iam Aafreen student of B.C.A. I am just a begginner in the field of progrramming...and fine myself unable in understanding the logic of many problems...I hav very little knowledge abt programming...can someone tell me how can I learn programming in C and become a better programmer.
Changed float to double,
Changed float to double, worked like a charm ;)
Can anyone tell me please
Can anyone tell me please what is wrong in my code;
#include<stdio.h>
#include<math.h>
#define d(x,y,a,b) (sqrt((x-a)*(x-a)+(y-b)*(y-b)))
void calc(int [][2],int);
void mergesort(int [][2],int,int);
void merge(int [][2],int,int,int);
void mergesort1(int [][2],int,int);
void merge1(int [][2],int,int,int);
int b[100001][2];
main()
{
int t,i,m,j,k,num[100001][2],o;
scanf("%d",&t);
char waste;
for(o=1;o<=t;o++)
{ do{waste=getchar();}while(waste<'0'||waste>'9');
m=waste-'0';
for(j=1;j<=m;j++)
scanf("%d%d",&num[j][0],&num[j][1]);
mergesort1(num,1,m);
j=1;
while(j<m)
{ i=num[j][0];
for(k=j+1;num[k][0]==i&&k<=m;k++);
mergesort(num,j,k-1);
j=k;
}
calc(num,m);
}
return 0;
}
void calc(int num[][2],int m)
{ int i,j=1,k,l;
double total=0;
while(j<m)
{ i=num[j][0];
for(k=j+1;num[k][0]==i&&k<=m;k++);
if(k>j+1&&k<=m)
{total+=fabs(-num[k-1][1]+num[j][1])+d(num[k-1][0],num[k-1][1],num[k][0],num[k][1]);}
else if(k>j+1&&k>m)
{total+=fabs(-num[k-1][1]+num[j][1]);}
else if(k==j+1)
{ total+=d(num[j][0],num[j][1],num[k][0],num[k][1]);}
j=k;
}
double t=total*100+0.5;
int y=floor(t);
t=(double)y/100;
printf("%.2lfn",t);
}
void mergesort1(int num[][2],int i,int j)
{
int mid;
if(i<j)
{ mid=(i+j)/2;
mergesort1(num,i,mid);
mergesort1(num,mid+1,j);
merge1(num,i,mid,j);
}
}
void merge1(int num[][2],int low,int mid,int high)
{
int i,j,k,l;
i=low;
j=mid+1;
for(k=low;i<=mid&&j<=high;)
if(num[i][0]<num[j][0])
{ b[k][0]=num[i][0];
b[k++][1]=num[i++][1];
}
else
{ b[k][0]=num[j][0];
b[k++][1]=num[j++][1];
}
if(i>mid)
for(l=j;l<=high;l++)
{ b[k][0]=num[l][0];
b[k++][1]=num[l][1];}
else if(j>high)
for(l=i;l<=mid;l++)
{ b[k][0]=num[l][0];
b[k++][1]=num[l][1];}
for(l=low;l<=high;l++)
{ num[l][0]=b[l][0];
num[l][1]=b[l][1];}
}
void mergesort(int num[][2],int i,int j)
{
int mid;
if(i<j)
{ mid=(i+j)/2;
mergesort(num,i,mid);
mergesort(num,mid+1,j);
merge(num,i,mid,j);
}
}
void merge(int num[][2],int low,int mid,int high)
{
int i,j,k,l;
i=low;
j=mid+1;
for(k=low;i<=mid&&j<=high;)
if(num[i][1]>num[j][1])
{ b[k][0]=num[i][0];
b[k++][1]=num[i++][1];
}
else
{ b[k][0]=num[j][0];
b[k++][1]=num[j++][1];
}
if(i>mid)
for(l=j;l<=high;l++)
{ b[k][0]=num[l][0];
b[k++][1]=num[l][1];}
else if(j>high)
for(l=i;l<=mid;l++)
{ b[k][0]=num[l][0];
b[k++][1]=num[l][1];}
for(l=low;l<=high;l++)
{ num[l][0]=b[l][0];
num[l][1]=b[l][1];}
}
seriously, guys. try using
use double,not float and
is the input sequence sorted
@cool_toad: No, the input
pls any1 say what is the
@remogoku: You are using
hey, i did it using
hey i m getting a TLE....can
hey i m getting a TLE....can
plz help Why
sorry for last comment..but
#include #include void
I m always getting right
Plz tell what is the problem
@mygaurav: total distance can
Thanks imnewcoder :)
WA WA WA,.. Can sum1 help..
what's wrong with my code i
#include #include int
Can anyone explain how 0,0