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 » November 2010 Challenge » Graph Challenge

Graph Challenge

Problem code: GRAPHCH

  • All Submissions

All submissions for this problem are available.

Statement

You are given a modified graph with N vertices and M edges. Each vertex is a rectangle [ dimension of each vertex may be different ] . Your task is to place these vertices in 2-d space such that :

  • No two vertices overlap [ remember, they are rectangles ]
  • All rectangles have their sides parallel to the axis.
  • Rectangles cannot be rotated.

For every edge in the graph, add the manhattan distance between the centres of the vertex for each edge as the cost of a solution ( C ).
Now, there might be multiple ways to achieve this. So, you have to strive to keep C as low as possible.

Input

First line contains t ( ? 100 ) equal to the number of test cases. For each test case, the first line contains 2 space separated integers ( N and M respectively ). Then M lines follow, each line containing 2 integers x and y ( 0 ? x,y < N , x ? y ) denoting an edge between vertex x and y. Then follow N lines, where line number i contains 2 integers a and b denoting the dimension of the ith vertex [ Here, a denotes the length parallel to x-axis and b denotes the length parallel to y-axis ]

( Note : If the same pair x,y appears multiple times, it denotes multiple edges and hence, each pair contributes to the cost ).

NOTE : Please note that all solutions will be tested on another set of test data after the contest which will follow the same pattern for test case generation ( as mentioned in 'Test Case Generation' section ). The final score for a solution will be the score of solution on latter test data.

Output

For each test case, print N lines , each containing 2 floating point numbers X and Y, denoting the co-ordinates of the centre of vertex i.
Note : -109 ? X,Y ? 109 . Solutions not following the mentioned constraints will be adjudged as wrong answer.
Please note that the answers may not be optimal

Scoring

The Score for a solution = (C+1).
Your total score is the sum of your score for all the test cases.
You have to keep the score as low as possible.

Constraints

2 ? N ? 50
1 ? M ? 200 [ The edges are randomly generated ]
1 ? a,b ? 100000
There can be multiple edges between a pair of vertices.
Additionally for 50% of the cases 2 ? N ? 20. Also, for about 50% of cases, all vertices are squares [ a = b ] of same size.

Test Case Generation

There are about 100 cases in total. For first 50 cases, the number of vertex ( n ) is chosen as a random number in the interval [3,20]. The number of edges (m) is chosen as a random number in the range [2, n*(n-1)/2]. Then all edges are chosen as random pair of integers. All vertex are given the same dimension with the probability 0.5 else they are given a random dimension in [1,100000] * [1,100000].
For other 50 cases, n is chosen as a random integer in the interval [3,50]. m is chosen randomly from [2, min( n*(n-1)/2, 200) ]. Rest of the procedure remains the same.

Sample Input


1
2 1
0 1
2 2
2 2

Sample Output


2 2
10 3

Score for sample output : 10.0 ( Better answers may be possible )


Author: anshuman_singh
Date Added: 1-09-2010
Time Limit: 20 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, 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.

Which of our submissions will

thocevar @ 3 Nov 2010 12:40 AM

Which of our submissions will be used for final testing? All of them, highest scoring on preliminary tests or the latest?

I agree this needs to be

triplem @ 4 Nov 2010 08:49 AM

I agree this needs to be answered. I hope it is the latest submission only, as opposed to allowing all submissions, which has some pretty bad flaws.

Can the edges of the graph

tomas5 @ 5 Nov 2010 07:56 PM
Can the edges of the graph cross each other?

Hello Admin My question is

shadow @ 6 Nov 2010 06:06 PM

Hello Admin My question is same as Tomaz!!

Guess "by default" it means

Oleg @ 7 Nov 2010 05:16 PM

Guess "by default" it means all submissions will be rejudged.

Based on your feedback, we

admin @ 10 Nov 2010 01:21 AM

Based on your feedback, we are planning to rejudge the last submission for every user on new test data. Will update you guys more about the exact scoring rules by tomorrow. Thanks for your patience.

Maybe at least 10 last

Oleg @ 10 Nov 2010 12:58 PM

Maybe at least 10 last submissions ? Will be pity if test time will be 9.0 but on real data will be TL that will give 0 points.

@oleg: +1 @admin: can yu

suh_ash2008 @ 10 Nov 2010 07:49 PM

@oleg: +1

@admin: can yu please clarify the question posted by oleg before the contest ends.

We will judge only the last

admin @ 10 Nov 2010 11:47 PM

We will judge only the last accepted submission. We will extend the time limit on the new data to try and ensure that the accepted solution does not time out.

I had a clarification

Looterguf @ 11 Nov 2010 09:02 AM

I had a clarification question: if the bounding rectangles of the vertices touch along edges (not the edges of the problem, the edges of the rectangles), does it count as overlap?

@Gurtej: rectangles are

david_adm @ 11 Nov 2010 01:08 PM

@Gurtej: rectangles are allowed to touch.

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