Computer Science Canada A CHALLENGE |
Author: | paulkwatyra [ Sat Jan 07, 2006 6:13 pm ] |
Post subject: | A CHALLENGE |
Mouse Move Most likely, you will notice that you have a mouse attached to your computer, which lets you move the cursor around the screen. Your job is to get between the mouse and the cursor. Suppose that the bottom left-hand corner of your screen is (0,0), and all points on the screen are given by integer co-ordinates (x, y) where 0 <= x <= c and 0 <= y <= r. Thus, the top-right corner of the screen is at position (c, r), bottom-right corner is (c, 0), and top-left corner is (0, r). When a mouse is moved, it sends a pair of integers (a, b), indicating that the cursor should be moved a units in the x-direction and b units in the y-direction. It is worth noting that this is relative motion (i.e., how far to move) rather than absolute motion (i.e., where to move). It is also worth noting that a and b may be positive, negative or zero. You can assume the mouse starts at position (0,0). You job is to read input messages (i.e., relative motion positions sent by the mouse) and update the cursor to the new position on the screen. Your output (to the screen) will be the position of the mouse after each move. If the mouse hits the screen boundary, it stops moving in that direction. For example, if the mouse is supposed to move (-100, -10) from its current position (30, 40), the final positions will be (0, 30): the mouse will hit the left-hand side boundary, but still manages to move down. Input is listed as pairs, the first pair being (c, r), followed by the relative motion pairs (x, y). The input is terminated when the mouse moves (0,0). The input will be contained in the file s2.in. Sample Input 1 100 200 10 40 -5 15 30 -30 0 0 Sample Output for Sample Input 1 10 40 5 55 35 25 Sample Input 2 30 40 30 40 -100 -10 0 0 Sample Output for Sample Input 2 30 40 0 30 |
Author: | zylum [ Sat Jan 07, 2006 7:07 pm ] |
Post subject: | |
this was question 1 or 2 on ccc last year... it was by far the easiest one. |
Author: | 1of42 [ Sun Jan 08, 2006 3:27 am ] |
Post subject: | |
Yeah. Maybe instead of "challenge", you should call it "who here has a pulse", since that's honestly all you need to solve it ![]() |
Author: | MysticVegeta [ Wed Jan 11, 2006 10:49 am ] |
Post subject: | |
Lol I remember this one although I did the junior contest. This was "Mouse calls" from "CCC Senior problem 1 2005". easy problem... I know every senior writing the ocntest got this one last year lol. |