当前位置:网站首页>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;
}边栏推荐
- 实现inotify配合rsync实时备份
- WPF measurement string display size
- 双目立体视觉摄像头的标定、矫正、世界坐标计算(opencv)
- Analysis on the true topic of "cost management" by Guangdong second-class cost engineer
- How to evaluate iFLYTEK AI translation pen P20 series? Is it worth buying?
- 空间导电盘式滑环材料的选择
- LSF-bsub命令
- Summary of document level symbols under different systems
- 导航 习题【微机原理】【习题】
- leetcode:724. 寻找数组的中心下标
猜你喜欢

如何从外表判断导电滑环的质量

THREEJS基础入门

Recruit | DBA Data Engineer every week with an annual salary of 35+. Dream of Kyushu and bright stars!

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

Threejs basic introduction

Report delivery engineer

Yolov6 training your own data record +yolov5 comparison test

leetcode:370. Interval addition
![[advanced ROS chapter] Lecture 4: duplicate names in ROS (nodes, topics and parameters)](/img/25/85e8c55605f5cc999a8e85f0a05f93.jpg)
[advanced ROS chapter] Lecture 4: duplicate names in ROS (nodes, topics and parameters)

Advances in computational imaging
随机推荐
I want to register my stock account online. How do I do it? In addition, is it safe to open a mobile account?
Topic39——78. 子集
Exit operation in project
Topic39——78. subset
Reinforcement learning weekly (issue 51): integration of PAC, ilql, RRL & model free reinforcement learning into micro grid control: overview and Enlightenment
Matlab output format control%d,%f,%c,%s usage
[advanced ROS chapter] lesson 2 custom header and source file encapsulation
导航 实验【微机原理】【实验】
Vipshop product details API interface (item_get- get vipshop product details interface), vipshop details API interface
【ROS进阶篇】第二讲 自定义头、源文件封装
tmux设置
Common methods of string class
Which brokerage commission is the lowest and safest
阿里巴巴关键字搜索商品API接口(item_search-按关键字搜索商品接口),阿里巴巴搜索API接口
直播预告 | PostgreSQL 内核解读系列第一讲:PostgreSQL 系统概述
Shutter bottomnavigationbar toggle page hold
Analysis of the factors affecting the transmission signal of the conductive slip ring
CORDIC based Signal Processor desgn
Knowledge distilling learning notes
不同系统下的文件层级符号小结