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 » Craft 2010 » Missile Problem

Missile Problem

Problem code: CRAFT01

  • All Submissions

You are a Fighter Pilot trainer. Recently you have had an innovative idea of testing the pilots. A series of obstacles will be placed in front of the pilots, and the target will be placed at the other side of the obstacles. The obstacles will have opening in between them. The pilot s test will be to find the perfect opening so that he can hit the target without hitting any of the obstacles. The problem is that in some combinations of obstacles the target cannot be hit. Your job is to find out if for a given set of obstacles the target is hittable or not. You are a Fighter Pilot trainer. Recently you have had an innovative idea of testing the pilots. A series of obstacles will be placed in front of the pilots, and the target will be placed at the other side of the obstacles. The obstacles will have opening in between them. The pilot s test will be to find the perfect opening so that he can hit the target without hitting any of the obstacles. The problem is that in some combinations of obstacles the target cannot be hit. Your job is to find out if for a given set of obstacles the target is hittable or not. The figure below shows the layout of an example maze.

Input

Your program is to read from standard input. The input consists of T test cases. The number of test cases T (1 T 30) is given in the first line of the input. Each test case starts with a line containing an integer W (2 W 100), the width of an archer line. The next line contains an integer N (2 N 20), the number of obstacles. The i-th line of the following N lines contains three integers Di, Li, Ri (1 Di W, 0 Li < Ri W), where 1 i N, Di represents the y-coordinate of the i-th obstacle, and Li and Ri represent the x-coordinates of the leftmost point and the rightmost point of the opening in the i-th obstacle, respectively. Note that Di Dj if i j.

Output

Your program is to write to standard output. Print exactly one line for each test case. Print YES , if there exists a position on the fire line from which a pilot can hit the target, otherwise, NO .

2
15
4
10 2 7
7 5 12
2 7 12
4 9 13
6
3
2 1 3
4 0 2
5 4 6

 

Output:
YES
NO


Date: 2010-02-24
Time limit: 25s
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.

how can the first test case

linuxfreak @ 10 Mar 2010 09:56 PM

how can the first test case result in yes for the given set of data???? obstacle @ 10 starts at 2 & ends at 7.. whereas obstacle @ 4 starts at 9 and ends at 13 ... so how come.. the result yes????

is there anyone??? what does

linuxfreak @ 10 Mar 2010 11:40 PM

is there anyone??? what does this mean "Note that Di Dj if i j." ... in  the input statement paragraph?? i still have no clue.. how the first case is giving yes!! :-o

where is the figure ?? plz

vishnoi_nitesh @ 11 Mar 2010 12:09 AM

where is the figure ??

plz clear the meaning of question.

Is the archer line from A to

alok @ 11 Mar 2010 06:23 PM

Is the archer line from A to B in fig. or the whole fire line from fig. ? Coordinates not given ??

i also cannot

mayank singh @ 11 Mar 2010 11:24 PM

i also cannot understand

please elaborate your first test case

 

how can the first test case result in yes for the given set of data???? obstacle @ 10 starts at 2 & ends at 7.. whereas obstacle @ 4 starts at 9 and ends at 13 ... so how come.. the result yes????

@Lucky: Whole line is the

amanatadmin @ 12 Mar 2010 01:29 AM

@Lucky: Whole line is the fire line. A and B are the just the points on the fire line

what is the positoin of

vish @ 12 Mar 2010 01:51 AM

what is the positoin of target???????????

its not clear from problem statement...

check out the 1st case

zero.code @ 12 Mar 2010 02:19 AM

check out the 1st case admin....it should give no!!!

yes... i agree with ankit on

dejavu @ 12 Mar 2010 02:28 AM

yes... i agree with ankit on that one...kindly verify the sampel output for 1st case

I haven't still got the

linuxfreak @ 12 Mar 2010 07:59 AM

I haven't still got the correct answer.. but i feel.. the target doesn't need to be in perpendicular direction... we can hit across to... see the first case... you can hit the target by using a tilted line... I hope.. m clear in my point...

Problem statement and test

ron @ 12 Mar 2010 03:19 PM

Problem statement and test cases are correct.

I'm agree with Nitin Kumar.

Yes nitin is right

amanatadmin @ 12 Mar 2010 05:07 PM

Yes nitin is right

what does width,W of the

dejavu @ 12 Mar 2010 05:39 PM
what does width,W of the archer line mean? is it the thickness of missile . or something to do with its lenght?? the problem statement text was in this way could u clarify what was the intended text " (1 Di W, 0 Li < Ri W)" is it Di

when will the solutions for

dejavu @ 14 Mar 2010 11:56 AM

when will the solutions for this problem be available???

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