Bestcoder Round #73 (Div.2) (Hdu 5630)

Source: Internet
Author: User

Rikka with Chess

Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 177 Accepted Submission (s): 161


Problem Descriptionyuta gives Rikka a chess board of sizenxm.

As we all know, on a chess board, every cell was either black or white and every and the cells that share a side had different Colors.

Rikka can choose any rectangle formed by board squares and perform a inversion, every white cell becomes black, and vice Versa.

Rikka wants to turn all cells into the same color, please tell Rikka the minimal number of inversions she need to achieve Her goal.

Inputthe First line contains a numberT(t≤ten) --the number of the testcases.

Each testcase contains and numbersn,m(n≤9,m≤9) .

Outputfor each testcase, print a single number which represents the answer.

Sample Input31 22 23 3

Sample Output122 Test instructions: to a n*m black-and-white rectangle, each time you can choose an arbitrarily long rectangle from the rectangle, the grid in which the inverse color, ask the minimum number of actions to make all the lattice color the same puzzle: Draw a graph can be found in the law between the two lines between the color of the grid is just reversed color, So we will be any line invert color can make two rows up and down lattice same color, so we operate the M/2 times, Operation finished, each column of the grid is the same color but adjacent to the two columns invert color at this time we will inverse color of the lattice inversion colors can be N/2, so the answer is N/2+M/2

  

Bestcoder Round #73 (Div.2) (Hdu 5630)

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.