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

16550번 - Odd Colouring 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB63375.000%

문제

There is a grid with R rows and C columns. Rows are numbered 0 to R − 1 and columns are numbered 0 to C − 1. Let the cell at row r and column c be denoted as (r, c). Troy will add N(N ≥ R + C) balls to the grid; the i-th ball will be added to cell ((i − 1) mod R,(i − 1) mod C). Ondrej will add M balls to the grid; the j-th ball will be added to cell (Xj, Yj). Multiple balls may be added to the same cell.

Every ball will be painted either black or white. Determine the number of ways to paint the balls such that every row and every column has an odd number of black balls. Compute the number of ways modulo 998244353.

입력

Line 1 contains four integers R, C, N, M (1 ≤ R, C, N ≤ 229; R + C ≤ N; 1 ≤ M ≤ 216).

Line 2 contains M integers X1, . . . , XM (0 ≤ Xj < R).

Line 3 contains M integers Y1, . . . , YM (0 ≤ Yj < C).

출력

Print one line with one integer, the number of ways.

제한

예제 입력 1

2 4 6 2
1 1
3 0

예제 출력 1

8

예제 입력 2

6 4 50 5
0 1 2 3 4
3 3 3 3 3

예제 출력 2

503245988

예제 입력 3

2 4 6 2
1 0
3 2

예제 출력 3

0

힌트

For the first example, Troy added balls to (0, 0),(1, 1),(0, 2),(1, 3),(0, 0),(1, 1) and Ondrej added balls to (1, 3),(1, 0).

출처

Contest > Waterloo's local Programming Contests > 30 September, 2018 E번

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

출처

대학교 대회

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

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