CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • February CookOff
    • February Long Contest
    • January CookOff
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » Algothika 2010 » Triangle Revisited

Triangle Revisited

Problem code: AD4

  • All Submissions

All submissions for this problem are available.

Cody is busy in making triangles, so he has got another problem here, there are a set of given integral points on a 2-D plane. Johnny needs to find out how many triangles can be drawn using the set of given points.

Input

First line of input consists of t (1<=t<=15) test cases, then t test cases follows 1st line consisting of n , the no. of the points (1<=n<=1000), and next n lines consisting of two integers, the x and the y co-ordinate of each point All coordinates have absolute values not larger than 10000

Output

The output must contain n lines of output, with 1 integer in each line. The integer is the number of possible triangles that could be formed using the set of all the given points.

Example

Input:
2
5
-1 -1
1 -1
0 -2
-2 -2
0 0
4
-1 -2
1 0
-1 1
0 -1


Output:
8
3


Date: 2010-02-28
Time limit: 1s
Source limit: 50000
Languages: C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK JS


  • Submit

Comments

  • Login or Register to post a comment.

Please check your test case

moneymachine @ 4 Mar 2010 06:34 PM

Please check your test case as for n=5 and for these given points ans = 10 .. check plz

Please post all your doubts

nirley.gupta @ 4 Mar 2010 08:12 PM

Please post all your doubts here or mail it to algothika.algochallenge@gmail.com

ALGOTHIKA ORGANIZER

Nirley Gupta

yes the answer for n=5 should

s4p3r_c1n0s @ 4 Mar 2010 08:16 PM

yes the answer for n=5 should be 9 and not 8.

sorry for inconvenience caused.

Join us also on

nirley.gupta @ 4 Mar 2010 08:43 PM

Join us also on facebook

ALGOTHIKA

Are the test cases corrected

jayeshdhamechai @ 4 Mar 2010 11:46 PM

Are the test cases corrected accordingly?

and it should be 10 for the sample case and not 9

proof: naming the points A,B,C,D,E

ABC,ABD,ABE

ACD,ACE

ADE

BCD,BCE

BDE

CDE

 

Reply ASAP

the sample output is correct,

s4p3r_c1n0s @ 5 Mar 2010 01:24 AM

the sample output is correct, there are 3 points collinear for n=5 input,

which will not form a triangle, so total no. of triangles is 9 not 10.

so as u are assuming the points to be A,B,C,D,E there will be no triangle named ADE

I am also reviewing the original output test cases, for any fault!

@admin can you explain how it

codegambler @ 5 Mar 2010 09:45 AM

@admin can you explain how it is 8. I am getting 9 for test case 2 i.e n=5

have you reviewed your

architjain @ 5 Mar 2010 01:29 PM

have you reviewed your original test cases??

The test data for this

suh_ash2008 @ 7 Mar 2010 06:49 PM

The test data for this problem is wrong!!! I m sure my first submission is right!!

@Admin: Can you please check this!!

i have reviewed all the test

s4p3r_c1n0s @ 7 Mar 2010 08:34 PM

i have reviewed all the test cases!

the output are correct corresponding to the inputs

there is still some problem persisting in ur code

plz figure it out!

@Admin: Thanks!! Figured it

suh_ash2008 @ 7 Mar 2010 09:06 PM

@Admin: Thanks!! Figured it out!!!

what should be the answer for

khyatigupta @ 8 Mar 2010 06:03 PM

what should be the answer for first case 8 or 9 ??

i m getting  8 and i m sure dat i m correct.

admin please check the test

code.freak @ 8 Mar 2010 07:46 PM

admin please check the test cases....might there is some discrepancy..

@ankit There is no problem

nirley.gupta @ 8 Mar 2010 07:49 PM

@ankit

There is no problem with test cases...

as you can see, we have receive quite successful submissions and test cases have been reviewed thoroughly

@khyatigupta the answer is 9

s4p3r_c1n0s @ 8 Mar 2010 08:19 PM

@khyatigupta

the answer is 9 not 8, plz check your algorithm

@ankit

i am sure i dont need to review any test case again

admin.algothika and

aarpit @ 9 Mar 2010 12:11 AM

admin.algothika and Nirley

for 1st testcase what is the output 8 or 9

i am getting 9

@Arpit Itz 9........

nirley.gupta @ 9 Mar 2010 12:15 AM

@Arpit

Itz 9........

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com