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 » March 2011 Challenge » Squares Game

Squares Game

Problem code: SQUAGAME

  • All Submissions

All submissions for this problem are available.

Fat Tony and Fit Tony are playing the square painting game. There are n squares drawn on a plane. The sides of the squares are parallel to the axes. Squares don't intersect, but some of them can be inside others. In his turn a player can choose any square and paint it's internal area black. All squares inside the painted one are also painted black. The player can't paint the squares that were already painted. The loser is the player who can't make a turn. Determine the winner of the game if both players play optimally and Fat Tony's turn is the first. Also if Fat Tony can win the game determine which square he has to paint on his first turn in order to win. If there are many squares which guarantee victory to Fat Tony choose the one with the smallest number.

Input

The first line of input contains t - the number of test cases. Each test case starts with n - the number of squares. Next n lines consist of three integers each x, y, a - the coordinates of the lowest left corner of the sqaure and the length of it's sides. The squares in the input are numbered from 1 to n in the order they are listed.

Constraints

1 <= t <= 10
1 <= n <= 50000
The total number of squares over all test cases in one file won't exceed 250000.
x, y won't exceed 108 in absolute value. a will be positive and less than 108.

Output

For each test case print "Fat x", where x - is the number of square which needs to be painted on the first turn in order to win (if there are many such square chose the one with the smallest number), if Fat Tony wins or "Fit" if Fit Tony wins.

Example

Input:
2
5
0 0 10
15 15 1
1 1 3
5 5 1
14 14 3
2
1 1 1
3 3 1

Output:
Fat 2
Fit


Author: spooky
Date Added: 26-12-2010
Time Limit: 5 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, TCL, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

Can I paint a square if it is

utkarsh_lath @ 1 Mar 2011 04:38 PM

Can I paint a square if it is partially painted ?

Also, can two sqares touch

utkarsh_lath @ 1 Mar 2011 04:44 PM

Also, can two sqares touch each other?

Is the output for the tc 1 is

PradeepAmradi @ 1 Mar 2011 04:48 PM

Is the output for the tc 1 is correct...?

@utkarsh lath You can paint

spooky @ 1 Mar 2011 04:57 PM

@utkarsh lath

You can paint the partially painted square. Squares won't touch.

Accepted with C++ 4.0.0-8 and

Oleg @ 5 Mar 2011 04:01 AM

Accepted with C++ 4.0.0-8 and got Runtime Error with C++ 4.3.2 with exactly same code...

Considering the first test

dexter_z @ 7 Mar 2011 11:09 AM
Considering the first test case input !!! The input param 15,15,1 and 14,14,3 are a pair of intersecting squares !! won't this violate the premises of the problem ??

@Ziaul: Look again carefully

shadow @ 7 Mar 2011 11:21 AM

@Ziaul: Look again carefully :)

@Ziaul::it's cordinate of

devrajchouhan @ 8 Mar 2011 06:36 PM

@Ziaul::it's cordinate of left,top of square

@Ivan Mistreanu - 1st

fura2 @ 12 Mar 2011 10:03 PM
@Ivan Mistreanu - 1st Mar,2011 16:57:48.
Does "Squares won't touch" mean that, for example, following data isn't included the input?
1
2
0 0 10
5 0 1

@Codechef team, It seems you

mkagenius @ 12 Mar 2011 11:56 PM

@Codechef team, It seems you people don't try to improve the Site.

"Oops, We are Sorry to load the recent activity"  is a constant business.

 

I guess you might have not noticed this, since you might be having blazing fast Internet, but most of the Indian Students don,t have.

Try Improving this, give a ranking page instead like that in cook-off, that is better than this Ajax .

What is importance of ajax, if gives 90% of the times  :    ------>    " Ooops"  .

 

Plz improve this thing as soon as possible.

How Can you guys be so lazy, cmon wake up.

@Yamazoe , I think that won't

mkagenius @ 12 Mar 2011 11:59 PM

@Yamazoe , I think that won't affect your answer , if you got the correct algorithm.

i.e. Assume 2nd square will get painted as soon as you paint the first one.

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