当前位置:网站首页>C. Where‘s the Bishop?
C. Where‘s the Bishop?
2022-06-29 21:35:00 【Felven】
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Mihai has an 8×88×8 chessboard whose rows are numbered from 11 to 88 from top to bottom and whose columns are numbered from 11 to 88 from left to right.
Mihai has placed exactly one bishop on the chessboard. The bishop is not placed on the edges of the board. (In other words, the row and column of the bishop are between 22 and 77, inclusive.)
The bishop attacks in all directions diagonally, and there is no limit to the distance which the bishop can attack. Note that the cell on which the bishop is placed is also considered attacked.
An example of a bishop on a chessboard. The squares it attacks are marked in red.
Mihai has marked all squares the bishop attacks, but forgot where the bishop was! Help Mihai find the position of the bishop.
Input
The first line of the input contains a single integer tt (1≤t≤361≤t≤36) — the number of test cases. The description of test cases follows. There is an empty line before each test case.
Each test case consists of 88 lines, each containing 88 characters. Each of these characters is either '#' or '.', denoting a square under attack and a square not under attack, respectively.
Output
For each test case, output two integers rr and cc (2≤r,c≤72≤r,c≤7) — the row and column of the bishop.
The input is generated in such a way that there is always exactly one possible location of the bishop that is not on the edge of the board.
Example
input
Copy
3 .....#.. #...#... .#.#.... ..#..... .#.#.... #...#... .....#.. ......#. #.#..... .#...... #.#..... ...#.... ....#... .....#.. ......#. .......# .#.....# ..#...#. ...#.#.. ....#... ...#.#.. ..#...#. .#.....# #.......
output
Copy
4 3 2 2 4 5
Note
The first test case is pictured in the statement. Since the bishop lies in the intersection row 44 and column 33, the correct output is 4 3.
Problem solving instructions : This question only needs to find the cross position , The simplest way is to traverse the entire chessboard , Find one 3X3 There are four directions in the square of # The location of , Then take the center .
#include"stdio.h"
#include"math.h"
int main()
{
char arr[9][9];
int a, b, t;
scanf("%d", &t);
while (t--)
{
for (int i = 1; i <= 8; i++)
{
for (int j = 1; j <= 8; j++)
{
scanf(" %c", &arr[i][j]);
}
}
for (int i = 1; i <= 8; i++)
{
for (int j = 1; j <= 8; j++)
{
if (arr[i][j] == '#' && arr[i][j + 2] == '#' && arr[i + 2][j] == '#'&&arr[i + 2][j + 2] == '#')
{
a = i + 1;
b = j + 1;
break;
}
}
}
printf("%d %d\n", a, b);
}
return 0;
}边栏推荐
- A keepalived high availability accident made me learn it again!
- 【云原生实战】KubeSphere实战——多租户系统实战
- String字符串的存储原理
- Shutter bottomnavigationbar with page switching example
- What problems should be avoided when using the points mall games for marketing?
- 习近平在湖北武汉考察时强调 把科技的命脉牢牢掌握在自己手中 不断提升我国发展独立性自主性安全性
- 唯品会商品详情API接口(item_get-获得唯品会商品详情接口),唯品会详情API接口
- 路由汇总带来的三层环路-解决实验
- Clock tree synthesis (CTS)
- Is it safe to open a securities account in Caixue school?
猜你喜欢
![Navigation [microcomputer principle]](/img/79/8311a409113331e72f650a83351b46.png)
Navigation [microcomputer principle]

Viewing technological changes through Huawei Corps (V): smart Park

路由汇总带来的三层环路-解决实验

习近平在湖北武汉考察时强调 把科技的命脉牢牢掌握在自己手中 不断提升我国发展独立性自主性安全性

STL tutorial 6-deque, stack, queue, list container

leetcode:370. 区间加法

Live broadcast preview | PostgreSQL kernel Interpretation Series Lecture 1: overview of PostgreSQL system

Implementation and Simulation of ads131a04 ADC Verilog

《强化学习周刊》第51期:PAC、ILQL、RRL&无模型强化学习集成于微电网络格控制:综述与启示

期末复习【微机原理】
随机推荐
GoAhead WebServer移植
Visual analysis and display effect of summer data
Digital password lock Verilog design + simulation + on board verification
【摸鱼神器】UI库秒变低代码工具——表单篇(一)设计
【ROS进阶篇】第四讲 ROS中的重名问题(节点、话题与参数)
Vipshop product details API interface (item_get- get vipshop product details interface), vipshop details API interface
Recruit | DBA Data Engineer every week with an annual salary of 35+. Dream of Kyushu and bright stars!
PostgreSQL每周新闻—6月22日
报表交付工程师
Vipshop Keyword Search API interface (item_search- search vipshop commodity API interface by keyword), vipshop API interface
如何评价科大讯飞AI翻译笔P20系列,值得买吗?
[advanced ROS chapter] Lecture 4: duplicate names in ROS (nodes, topics and parameters)
VHDL电话计费系统设计
STL tutorial 6-deque, stack, queue, list container
Application of VoIP push in overseas audio and video services
How to call RFC function of ABAP on premises system directly in SAP BTP ABAP programming environment
Knowledge distilling learning notes
Goahead translation - Active Server Pages
Win10 add SSH public key
《强化学习周刊》第51期:PAC、ILQL、RRL&无模型强化学习集成于微电网络格控制:综述与启示