Chessboard Game

시간 제한1초메모리 제한1024 MB

요약
위나 왼쪽으로만 한 칸씩 움직이며 경계 칸의 천국문과 지옥문을 만나는 게임에서, 여러 시작 칸 각각에 대해 선공이 이기는지 판정한다.
난이도

보통10점 중 7점

유형
게임 이론, 동적 계획법, 누적 합, 수학
정답자
아직 제출이 없습니다

문제

bobo and yiyi are playing a game on a chessboard with (n+1)(n + 1) rows and (m+1)(m + 1) columns. Rows are numbered by 0,1,…,n0, 1, \dots, n from top to bottom, while columns are numbered by 0,1,…,m0, 1, \dots, m from left to right.

Cells (0,1),(0,2),…,(0,m),(1,0),(2,0),…,(n,0)(0, 1), (0, 2), \dots, (0, m), (1, 0), (2, 0), \dots, (n, 0) are special. They may contain a "heaven gate" or "hell gate". People who enters a "heaven gate" immediately wins. However, the one who enters a "hell gate" dies and gives the victory to the other.

The game lasts for qq rounds. In each round, a chess is placed on cell (x_i,y_i)(x\_i, y\_i) initially. bobo and yiyi moves alternatively. bobo goes first. In one move, chess can be moved one cell upward or leftward.

Determine if bobo can win for each round. You know, bobo and yiyi are really clever guys ...

입력

The first line contains 33 integers n,m,qn, m, q (1≤n,m,q≤2⋅1051 \leq n, m, q \leq 2 \cdot 10^5).

The second line contains nn integers a_1,a_2,…,a_na\_1, a\_2, \dots, a\_n (0≤a_i≤10 \leq a\_i \leq 1). If cell (i,0)(i, 0) contains a "heaven gate", then a_i=0a\_i = 0. If cell (i,0)(i, 0) contains a "hell gate" instead, then a_i=1a\_i = 1.

The third line contains mm integers b_1,b_2,…,b_mb\_1, b\_2, \dots, b\_m (0≤b_i≤10 \leq b\_i \leq 1). If cell (0,i)(0, i) contains a "heaven gate", then b_i=0b\_i = 0. If cell (0,i)(0, i) contains a "hell gate" instead, then b_i=1b\_i = 1.

Each of the last qq lines contains 22 integers x_i,y_ix\_i, y\_i (1≤x_i≤n,1≤y_i≤m1 \leq x\_i \leq n, 1 \leq y\_i \leq m).

출력

For each rounds, print "Yes" if bobo can win. Print "No" otherwise.

예제1

  1. 예제 1

    입력
    2 2 4
    10
    11
    1 1
    1 2
    2 1
    2 2
    
    예상 출력
    No
    Yes
    Yes
    No