Logo
(追記) (追記ここまで)

6877번 - Mouse Move 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB1391099877.165%

문제

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).

입력

출력

제한

예제 입력 1

100 200
10 40
-5 15
30 -30
0 0

예제 출력 1

10 40
5 55
35 25

예제 입력 2

30 40
30 40
-100 -10
0 0

예제 출력 2

30 40
0 30

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2005 > CCC 2005 Senior Division 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /