ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

1.29我的第十二篇

2022-01-29 20:33:20  阅读:217  来源: 互联网

标签:第十二 rr cc cell column 1.29 black row


题目链接​​​​​​https://acs.jxnu.edu.cn/contest/23/board/challenge/A

题目:Not Shading

描述:

There is a grid with nn rows and mm columns. Some cells are colored black, and the rest of the cells are colored white.

In one operation, you can select some black cell and do exactly one of the following:

  • color all cells in its row black, or
  • color all cells in its column black.

You are given two integers rr and cc. Find the minimum number of operations required to make the cell in row rr and column cc black, or determine that it is impossible.

输入:

The input consists of multiple test cases. The first line contains an integer tt (1≤t≤1001≤t≤100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains four integers nn, mm, rr, and cc (1≤n,m≤501≤n,m≤50; 1≤r≤n1≤r≤n; 1≤c≤m1≤c≤m) — the number of rows and the number of columns in the grid, and the row and column of the cell you need to turn black, respectively.

Then nn lines follow, each containing mm characters. Each of these characters is either 'B' or 'W' — a black and a white cell, respectively.

输出:

For each test case, if it is impossible to make the cell in row rr and column cc black, output −1−1.

Otherwise, output a single integer — the minimum number of operations required to make the cell in row rr and column cc black.

我的翻译:

有一个n*m大小的矩阵,里面有n*m个方格,方格的颜色只有黑和白两种。判断需要经过几次操作是否能将指定的方格涂层黑色。以下有两种操作:只能将含有黑色的方格所在行或者所在列都涂成黑色。

输入:第一行输入一个整数 t ,代表接下来有 t 组矩阵。第二行输入 n,m,c,r。表示矩阵的大小以及需要被涂成黑色方格的坐标。

输出:如果不需要操作 则输出 0,如果不能操作,则输出 -1,如果可以操作 ,则输出最小的操作次数。 

标签:第十二,rr,cc,cell,column,1.29,black,row
来源: https://blog.csdn.net/WycRs/article/details/122747168

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有