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

22200번 - Plus Minus 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB40222156.757%

문제

Matthew the physicist studies the quantum electro-dynamics of a silicon-based rectangular microchip. The microchip consists of a very large N ×M grid of electrons. Each electron has either positive (up) or negative (down) spin, denoted by + and − respectively.

Matthew does not know the spin of all the electrons, but he has done K measurements. In the i-th measurement, he discovered that the electron at position (yi, xi) has a given spin si. He also knows that in each 2 × 2 subgrid, there are equally many electrons with positive and negative spin. He wants to know whether he can recover the state of every electron based on his measurements. If not, he would like to know how many possible states are consistent with his measurements. For classified reasons, he wants the answer modulo 109 + 7.

입력

The first line contain three numbers N, M and K: the height of the grid, the width of the grid and the number of measurements. The next K lines contain a spin si where si is either + or -, and two numbers 1 ≤ yi ≤ N and 1 ≤ xi ≤ M – the coordinates of the electron. Matthew never did two measurments at the exact same location.

출력

Output the total number of valid states consistent with Matthew’ measurements modulo 109 + 7.

제한

We always have 1 ≤ N, M ≤ 109 and 0 ≤ K ≤ 100 000. For subcases, the inputs have these further restrictions.

서브태스크

번호배점제한
112

N, M ≤ 5

242

N, M ≤ 1 000

346

No further restrictions.

예제 입력 1

2 4 4
+ 1 1
- 1 2
+ 1 3
- 1 4

예제 출력 1

2

The only two valid grids are

+-+-
+-+-

and

+-+-
-+-+

예제 입력 2

3 3 3
- 2 1
+ 2 3
+ 3 3

예제 출력 2

0

힌트

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2017 F번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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