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 » 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


Author: aman871988
Date Added: 24-02-2010
Time Limit: 25 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, C, C99 strict, CAML, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, FORT, HASK, ICON, JAR, JAVA, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST


  • 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 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