当前位置:网站首页>C. Where‘s the Bishop?
C. Where‘s the Bishop?
2022-06-29 15:36: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.
解题说明:此题只需要找到交叉位置即可,最简单的办法就是遍历整个棋盘,找到一个3X3的正方形其中四个方向都存在#的位置,那么取中心即可。
#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;
}边栏推荐
- Several imaging modes of polarimetric SAR
- 有望显著提高集成光子电路的计算性能,清华团队提出了一种衍射图神经网络框架
- TDesign, which gave us benefits last time, will tell us its open source story today
- What are the advantages of intelligent chat robots? Senior independent station sellers tell you!
- 14.ip protocol -bite
- 11. application layer data transmission format / port number -bite
- Training mode of deep learning network
- taro3.*中使用 dva 入门级别的哦
- About sql+nosql: newsql database
- PostgreSQL source code learning (24) -- transaction log ⑤ - log writing to wal buffer
猜你喜欢
随机推荐
天谋科技 Timecho 完成近亿元人民币天使轮融资,围绕 Apache IoTDB 打造工业物联网原生时序数据库
Business Intelligence BI and business management decision-making thinking No. 3: business quality analysis
What is the time complexity of the redis command?? (the actual question is about the underlying structure of redis)
Andorid Jetpack Hilt
wallys/m.2/Adapter card(one pcie1x to 4 x Mini PCIE)
wallys/m.2/Adapter card(one pcie1x to 4 x Mini PCIE)
Imgutil image processing tool class, text extraction, image watermarking
List集合详细讲解
Mysql database naming conventions PDF
LeetCode-64-最小路径和
Alibaba cloud experience Award: use polardb-x and Flink to build a large real-time data screen
taro3.*中使用 dva 入门级别的哦
Neural network for remote sensing image processing
Leetcode-64- minimum path sum
GWD:基于高斯Wasserstein距离的旋转目标检测 | ICML 2021
14.IP协议-bite
12.UDP协议-bite
13.TCP-bite
Introduction to radar antenna
瓜分1000+万奖金池,昇腾AI创新大赛2022实力赋能开发者









