当前位置:网站首页>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;
}边栏推荐
- three. JS and Gaode map are combined to introduce obj format model - effect demonstration
- 墨天轮“高可用架构”干货文档分享(含Oracle、MySQL、PG资料124篇)
- Go标准库Context包:单个请求多个goroutine 之间与请求域的数据、取消信号、截止时间等相关操作
- 13.TCP-bite
- 硬件开发笔记(八): 硬件开发基本流程,制作一个USB转RS232的模块(七):创建基础DIP元器件(晶振)封装并关联原理图元器件
- Polarimetric SAR surface classification
- Three development trends of enterprise application viewed from the third technological revolution
- C#学习一:值类型与引用类型
- Taro中添加小程序 “lazyCodeLoading“: “requiredComponents“,
- Motion capture system for apple picking robot
猜你喜欢

Interviewer: tell me about the MySQL transaction isolation level?

架构实战营模块五作业

Paging SQL (rownum, row_number, deny_rank, rank)

动作捕捉系统用于苹果采摘机器人

It is expected to significantly improve the computational performance of integrated photonic circuits. The Tsinghua team proposed a diffraction pattern neural network framework

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

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

ROS2机器人f1tenth之CLI工具基础

Leetcode-64- minimum path sum

如何使用SMS向客户传递服务信息?指南在这里!
随机推荐
PostgreSQL source code learning (25) -- transaction log ⑥ - wait for log writing to complete
C language homework - matching system
radar transmitter
. Net program configuration file operation (INI, CFG, config)
Polarimetric SAR surface classification
14.IP协议-bite
GWD: rotating target detection based on Gaussian Wasserstein distance | ICML 2021
DataKit 作为本地获取数据的 API 服务器
The way of enterprise transformation and upgrading: digital transformation, thinking first
Imgutil image processing tool class, text extraction, image watermarking
ROS2机器人f1tenth之CLI工具基础
《网络是怎么样连接的》读书笔记 - WEB服务端请求和响应(五)
微信公告号 图灵机器人实现智能回复
Symfony framework security component firewall configuration
postgresql源码学习(25)—— 事务日志⑥-等待日志写入完成
从第三次技术革命看企业应用三大开发趋势
Dynamically listening for DOM element height changes
2022年第一季度保险服务数字化跟踪分析
Leetcode-470- implement rand10() with rand7()
Middle order and post order traversal to construct binary tree [recursive partition interval and backtracking splicing subtree + similarity and difference between middle post order and middle pre orde