当前位置: 首页 > news >正文

CF1692C Where‘s the Bishop? 题解

CF1692C Where's the Bishop? 题解

  • 题目
    • 链接
    • 字面描述
      • 题面翻译
      • 题目描述
      • 题目描述
      • 输入格式
      • 输出格式
      • 样例 #1
        • 样例输入 #1
        • 样例输出 #1
      • 提示
  • 代码实现

题目

链接

https://www.luogu.com.cn/problem/CF1692C

字面描述

题面翻译

题目描述

有一个8×88\times88×8的棋盘,列编号从左到右递增,行编号从上到下递增。

给出一个棋盘,上面用KaTeX parse error: Expected 'EOF', got '#' at position 1: #̲标明了主教的攻击范围。请你找出主教的位置坐标,并输出其行、列编号。

保证:主教的行、列编号均在222777之间。

你需要回答ttt组测试数据。 (1≤t≤36)(1\le t \le 36)(1t36)

题目描述

Mihai has an $ 8 \times 8 $ chessboard whose rows are numbered from $ 1 $ to $ 8 $ from top to bottom and whose columns are numbered from $ 1 $ to $ 8 $ 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 $ 2 $ and $ 7 $ , 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.

输入格式

The first line of the input contains a single integer $ t $ ( $ 1 \leq t \leq 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 $ 8 $ lines, each containing $ 8 $ characters. Each of these characters is either ‘#’ or ‘.’, denoting a square under attack and a square not under attack, respectively.

输出格式

For each test case, output two integers $ r $ and $ c $ ( $ 2 \leq r, c \leq 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.

样例 #1

样例输入 #1

3.....#..
#...#...
.#.#....
..#.....
.#.#....
#...#...
.....#..
......#.#.#.....
.#......
#.#.....
...#....
....#...
.....#..
......#.
.......#.#.....#
..#...#.
...#.#..
....#...
...#.#..
..#...#.
.#.....#
#.......

样例输出 #1

4 3
2 2
4 5

提示

The first test case is pictured in the statement. Since the bishop lies in the intersection row $ 4 $ and column $ 3 $ , the correct output is 4 3.

代码实现

遍历每一个点看他的四个角和本身是不是"#"即可

#include<bits/stdc++.h>
using namespace std;const int maxn=20;
int t;
char a[maxn][maxn];
inline bool inbound(int x,int y){return x>=1&&x<=8&&y>=1&&y<=8;}
int main(){scanf("%d",&t);while(t--){for(int i=1;i<=8;i++){for(int j=1;j<=8;j++)scanf(" %c",&a[i][j]);}bool flag=false;for(int i=1;i<=8;i++){for(int j=1;j<=8;j++){if(a[i][j]=='#'&&a[i-1][j+1]=='#'&&a[i-1][j-1]=='#'&&a[i+1][j-1]=='#'&&a[i+1][j+1]=='#'){printf("%d %d\n",i,j);break;}}if(flag)break;}}return 0;
}
http://www.lryc.cn/news/18128.html

相关文章:

  • Jenkins集成Allure报告
  • 【数据结构】AVL树
  • 这一次我不再低调,老板法拉利的车牌有我的汗水
  • 通过连接另一个数组的子数组得到一个数组
  • 公派访问学者的申请条件
  • 多点电容触摸屏实验
  • 【算法与数据结构(C语言)】栈和队列
  • Uni-app使用vant和uview组件
  • 2023年PMP考试应该注意些什么?
  • selenium环境安装及使用
  • 高性能低功耗4口高速USB2.0 HUB 完美替代FE1.1S和FE8.1
  • Go全栈学习(一)基础语法
  • centos7搭建svn配置
  • 趣味三角——第12章——tanx
  • Java - 数据结构,栈
  • 某餐厅系统网络故障分析案例
  • 华为OD机试题,用 Java 解【密室逃生游戏】问题
  • 如何重命名SQL Server数据库
  • 联想昭阳E5-ITL电脑开机后绿屏怎么U盘重装系统?
  • 车载开发知识交流【学习路线】
  • 【读书笔记】《深入浅出数据分析》第二章 检验你的理论
  • pyflink学习笔记(一):table_apisql
  • GCC 编译器套件说明
  • IDEA集成Git
  • 算法流程图
  • Java中安装JDK环境–javac命令无效
  • 递推问题
  • js中强制类型转换Number、parseInt、parseFloat、Boolean、String、toString的使用
  • 漏斗分析法
  • pycharm入门快捷操作(部分)