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
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » May 2010 Contest » Nice Quadrangles

Nice Quadrangles

Problem code: NICEQUAD

  • All Submissions

All submissions for this problem are available.

There are n points with integer coordinates. We can form different quadrangles out of them by taking four different points and connecting them with lines. Let s call a quadrangle ABCD nice if and only if:

  • Ax > 0 and Ay > 0;
  • Bx > 0 and By < 0;
  • Cx < 0 and Cy < 0;
  • Dx < 0 and Dy > 0;
  • ABCD has an integer area.

Your task is to count all different nice quadrangles that can be formed on the given points.

Input

The first line of input file contains number t the number of test cases. Then the description of each test case follows. The first line of each test case contains number n the number of points. Then n lines follow each consisting of two integers x, y the coordinates of a point. No two points in the same test case coincide.

Constraints

1 <= t <= 10
1 <= n <= 30000
-30000 <= x, y <= 30000

Output

For each test case print the number of nice quadrangles that can be formed using given points.

Example

Input:
1
6
1 1
2 2
-1 -1
-2 2
2 -1
-3 -4

Output:
2


Author: spooky
Date Added: 9-04-2010
Time Limit: 1 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

can you explain how answer is

codegambler @ 1 May 2010 03:41 PM

can you explain how answer is 2.

According to my understanding is will be 4 the quardangles are.

1> (1,1) (2,-1) (-3,-4) (-2,2)

2> (1,1) (2,-1) (-1,-1) (-2,2)

3> (2,2) (2,-1) (-3,-4) (-2,2)

4> (2,2) (2,-1) (-1,-1) (-2,2)

 

or sorry got it.

codegambler @ 1 May 2010 03:43 PM

or sorry got it.

can you explain how answer is

rahulmanglani @ 1 May 2010 04:56 PM

can you explain how answer is 2????

Comment edited by Admin

hi_i_am_amit @ 1 May 2010 06:12 PM

Comment edited by Admin

@Amit. Posting or asking for

admin @ 1 May 2010 07:45 PM

@Amit. Posting or asking for hints is not permitted. Violation of rules may lead to banning in future contests.

@Admin: none of the Java

keghani @ 1 May 2010 10:26 PM

@Admin: none of the Java programs so far have been successful - or even gotten wrong answers.  we all keep timing out!  i've gone to crazy lengths to optimize on this particular problem.  i'll get banned if i say any more on that.  just one request please, can one of you guys higher up actually code this in Java and measure us against that, instead of doubling the default time limit?  so we'll at least know whether we're on the right algorithm, or just forever wrong because of our choice of language?

@Admin : Sorry for that

hi_i_am_amit @ 1 May 2010 11:05 PM

@Admin : Sorry for that comment.

May i ask what an integer

brien_premachandiran @ 2 May 2010 01:18 AM

May i ask what an integer area is?

OK, my question is about "all

loopback @ 2 May 2010 02:26 AM

OK, my question is about "all different nice quadrangles". Does it mean different shape of the quadrangles? For example following coordinates describes one quadrangle (square) but placed elsewhere in the coordinate system (ABCD and EFGH):

A(-3,3), B(3,3), C(3,-3), D(-3,-3), E(-2,2), F(4,2), G(4,-4), H(-2,-4)

Please explain me if those quadrangles (ABCE and EFGH) are the same in meaning from description of task.

@Brien an integer area is

keghani @ 2 May 2010 02:48 AM

@Brien an integer area is that which has a whole number as its value.  e.g.:

if a quadrangle has an area of 22.5 units, that is not an integer area.

if a quadrangle has an area of 17 units, that is an integer area.

Hmmm... sorry for my stupid

loopback @ 2 May 2010 03:24 AM

Hmmm... sorry for my stupid question. It's explained in Qutput section: "For each test case print the number of nice quadrangles that can be formed using given points.".

beautiful; i submitted code

keghani @ 2 May 2010 03:33 AM

beautiful; i submitted code (in Java) that reads all the input and prints a single "0" per test case, no computations; it timed out.

18th submission finally got

sidi @ 2 May 2010 06:35 PM

18th submission finally got AC. Phew!!

i'm also a programmer in java

sheku @ 2 May 2010 06:52 PM

i'm also a programmer in java but i'm a high school student and i think all other programmers in JAVA should be satisfied with their programmes if they run successfully in their respective PCs. if they can they should start up their own ONLINE ''JAVA" programming competetion. i'd be waiting for that

I am a Java programmer and I

sppraveen @ 3 May 2010 12:57 AM

I am a Java programmer and I believe java programmer are not in a downside of advantage as we are given 2x time limits. tweak your algos . i have been participating for  while and I can say this with confidence.

Yeah, you need to prune your

Tool @ 3 May 2010 01:17 PM

Yeah, you need to prune your I/O code to be efficient as well.  Personally, I find it unfortunate that I/O must also be tweaked to get below the time limit, but apparently it can be done. Fear not, once you optimize your I/O once, you can recycle that piece for the next n times   :D

@admins : The judge gives a

ankul_iiita @ 3 May 2010 08:38 PM

@admins : The judge gives a Wrong answer just at the first case it finds wrong instead of evaluating the whole set of test cases and then showing TLE or WA according to the submission. As a result, even the codes that will TLE on large test cases and giving wrong answer for smaller test cases do give WA instead of TLE. This is really confusing :( Judge's checker needs to be modified or the largest test case should be there in the beginning of test cases.

@Ankul: There can be multiple

rockaustin2k6 @ 3 May 2010 08:54 PM

@Ankul: There can be multiple test files.So, it's better to submit a correct code instead of experimenting with the test cases :D

9th submission and its

calc_saransh @ 3 May 2010 09:08 PM

9th submission and its correct... my first solution in a running contest... and ya java works fine.. no probs with that.. optimise ur algo... :) :)

My name is not in over all

codegambler @ 5 May 2010 01:24 PM

My name is not in over all ranking list?

if 3 points out of the 4 are

arijit91 @ 5 May 2010 03:52 PM

if 3 points out of the 4 are collinear, will it still be considered a valid quadrangle?

That question does not need

triplem @ 5 May 2010 04:03 PM

That question does not need to be answered.

Should we take the input from

bramu.ss @ 6 May 2010 07:35 PM

Should we take the input from the file or from the command line??

 

i dont like the new code

vdmedragon @ 9 May 2010 12:30 PM

i dont like the new code submit interface (with color, line ...) . thus a simple one? How can I obtain it?  There is an option to do it?

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 algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm 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 programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were 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 challenges 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 coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

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. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

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