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

6771번 - Mouse Journey 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB58504888.889%

문제

You are a mouse that lives in a cage in a large laboratory. The laboratory is composed of one rectangular grid of square cages, with a total of R rows and C columns of cages (1 ≤ R, C ≤ 25).

To get your exercise, the laboratory owners allow you to move between cages. You can move between cages either by moving right between two adjacent cages in the same row, or by moving down between two adjacent cages in the same column. You cannot move diagonally, left or up.

Your cage is in one corner of the laboratory, which has the label (1, 1) (to indicate top-most row, left-most column). You would like to visit your brother who lives in the cage labelled (R, C) (bottom-most row, right-most column), which is in the other corner diagonally. However, there are some cages which you cannot pass through, since they contain cats.

Your brother, who loves numbers, would like to know how many different paths there are between your cage and his that do not pass through any cat cage. Write a program to compute this number of cat-free paths.

입력

The first line of input contains two integers R and C, separated by one space representing the number of rows and columns (respectively). On the second line of input is the integer K, the number of cages that contain cats. The next K lines each contain the row and column positions (in that order) for a cage that contains a cat. None of the K cat cages are repeated, and all cages are valid positions. Note also that (1, 1) and (R, C) will not be cat cages.

출력

Output the non-negative integer value representing the number of paths between your cage at position (1, 1) and your brother’s cage at position (R, C). You can assume the output will be strictly less than 1 000 000 000.

제한

예제 입력 1

2 3
1
2 1

예제 출력 1

2

예제 입력 2

3 4
3
2 3
2 1
1 4

예제 출력 2

1

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2012 > CCC 2012 Senior Division 5번

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

출처

대학교 대회

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

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