i got time limit.
i just calculate the value of k for each given point
for every i and j (i<j) by using given equation.then
check if k<0 and increment count.then at last print
the value of count.
so why time limit?
need better process?
11004 - Changing Roadmap
Moderator: Board moderators
-
- New poster
- Posts: 6
- Joined: Sun Nov 27, 2005 8:24 am
- Location: India
I am not sure why I kept getting WA, is there anything else except the repeating points that is tricky in the input?
What I did was:
1. Get rid of duplicate points
2. For all lines, get the value of ax+by+c for all points (just if it is positive or negative)
3. For all points, count how many positives(p) and how many negatives (n) are there, if(p>1) add p*(p-1)/2 to the sum, same for n
4. Print out the sum
I used longs, I thought that should do it.
Darko
What I did was:
1. Get rid of duplicate points
2. For all lines, get the value of ax+by+c for all points (just if it is positive or negative)
3. For all points, count how many positives(p) and how many negatives (n) are there, if(p>1) add p*(p-1)/2 to the sum, same for n
4. Print out the sum
I used longs, I thought that should do it.
Darko
valfiros wrote:I got TLE too...
I thought,
1. if A and B has same sign ,
2. K is minus in A + BK = 0.
but how can i upgrade my process from O(n^3) to O(n^2) or O(n)?
I used three loop ( n^2 * pp ) , but i couldn't find out more good algrothm.
Plsase suggest me something better![]()
-JSKim@CAC wrote-
you know that n C 2 = n(n-1) / 2
don't need a loop to get it..
-
- New poster
- Posts: 6
- Joined: Sun Nov 27, 2005 8:24 am
- Location: India
Why i got WA?
My algorithm not work.
For every PP (x, y):
I count the equations such that Ai*x+Bi*y+Ci < 0, be this count neg.
Increment the general result in neg*(neg - 1) / 2 and be pos = N - neg increment too in pos*(pos - 1) / 2.
That is now correct and don't occurs duplicate important places.
ivan
For every PP (x, y):
I count the equations such that Ai*x+Bi*y+Ci < 0, be this count neg.
Increment the general result in neg*(neg - 1) / 2 and be pos = N - neg increment too in pos*(pos - 1) / 2.
That is now correct and don't occurs duplicate important places.
ivan
Last edited by ivan.cu on Mon Aug 21, 2006 4:28 pm, edited 1 time in total.