当前位置:网站首页>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;
}边栏推荐
- golang gopsutil库的使用:进程和系统资源监控(CPU 内存 磁盘等)
- C language big job - Matching System
- Introduction to radar antenna
- 【云原生】Nacos-TaskManager 任务管理的使用
- Mysql database naming conventions PDF
- Google software version experience cycle
- 京东联盟API - 万能转链接口 - 京品库接口 - 接口定制
- Symfony framework security component firewall configuration
- C SQLite class library
- Interviewer: tell me about the MySQL transaction isolation level?
猜你喜欢

智能聊天机器人的优势在哪里?资深独立站卖家告诉你!

京东联盟API - 万能转链接口 - 京品库接口 - 接口定制

MySQL XA distributed transaction

Google software version experience cycle

Pre war minesweeping: five measures for vulnerability management

ROS2机器人f1tenth之CLI工具基础

Detailed explanation of list set

企业转型升级之道:数字化转型,思想先行

C#学习一:值类型与引用类型

three.js和高德地图结合引入obj格式模型-效果演示
随机推荐
GWD: rotating target detection based on Gaussian Wasserstein distance | ICML 2021
为Golang项目编写Makefile
Cmake learning-2
golang操作etcd
架构实战营模块五作业
three. JS and Gaode map are combined to introduce obj format model - effect demonstration
Pre war minesweeping: five measures for vulnerability management
C SQLite class library
小程序判断数据为不为空
等保测评结论为差,是不是表示等保工作白做了?
C#学习二:堆和栈
Complex convolutional neural network: cv-cnn
R语言plotly可视化:plotly可视化箱图、可视化多个分类变量的箱图(Several Box Plots)
postgresql源码学习(23)—— 事务日志④-日志组装
The way of enterprise transformation and upgrading: digital transformation, thinking first
13.TCP-bite
"Game engine shallow in shallow out" 98 Substancepainer plug-in development
Scroll, do you understand?
Building SQL statements in Excel
Training mode of deep learning network