시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 12 | 10 | 10 | 83.333% |
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.
번호 | 배점 | 제한 |
---|---|---|
1 | 12 | N, M ≤ 5 |
2 | 42 | N, M ≤ 1 000 |
3 | 46 | No further restrictions. |
2 4 4 + 1 1 - 1 2 + 1 3 - 1 4
2
The only two valid grids are
+-+- +-+-
and
+-+- -+-+
3 3 3 - 2 1 + 2 3 + 3 3
0