Hdu-1175-continuous view

Source: Internet
Author: User

The difficulty of this question is to count the number of turns.

 

Serialization

Time Limit: 20000/10000 ms (Java/Other) Memory Limit: 65536/32768 K (Java/Other)
Total Submission (s): 29 Accepted Submission (s): 12
Font: Times New Roman | Verdana | Georgia
Font Size: bytes →
Problem Description
I believe a lot of people have played "continuous watching. It doesn't matter if you haven't played it. Next I will introduce you to the game rules: a board contains a lot of pawns. If two of the same pawns can be connected through a line (this line cannot pass through other pawns), and the number of turns of the line cannot exceed two times, then the two pieces can be removed from the board. Sorry, because I have never played in the past, and I have consulted my colleagues, the connection cannot be bypassed from outside, but in fact this is wrong. Now it has become a serious disaster, so we can only make mistakes, and the connections cannot be bypassed from the periphery.
The player clicks two pawns one by one, tries to remove them, and then checks whether the two squares can be deleted in the background of the game. Now your task is to write this background program.

Input
There are multiple groups of input data. The first row of each group of data has two positive integers n, m (0 <n <= 1000, 0 <m <), indicating the number of rows and columns of the Board respectively. In the next n rows, each row has m non-negative integers to describe the square distribution of the Board. 0 indicates that there is no pawn in this position, and a positive integer indicates the type of the pawn. The next row is a positive integer q (0 <q <50), indicating that there are q queries below. In the next q row, each row has four positive integers x1, y1, x2, y2, which indicates whether the pawns in column y1 of row x1 can be deleted from column y2 of row x2. When n = 0 and m = 0, the input ends.
Note: There is no sequential relationship between the queries. They are all in the current state!

Output
Each group of input data corresponds to a row of output. If YES, "YES" is output. If NO, "NO" is output ".

Sample Input
3 4
1 2 3 4
0 0 0 0
4 3 2 1
4
1 1 3 4
1 1 2 4
1 1 3 3
2 1 2 4
3 4
0 1 4 3
0 2 4 1
0 0 0 0
2
1 1 2 4
1 3 2 3
0 0
Sample Output
YES
NO
NO
NO
NO
YES
 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.