A11350 | Vlad and Shapes
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vladislav has a binary square grid of $n \times n$ cells. A triangle or a square is drawn on the grid with symbols $\texttt{1}$ . As he is too busy being cool, he asks you to tell him which shape is drawn on the grid.
- A triangle is a shape consisting of $k$ ( $k>1$ ) consecutive rows, where the $i$ -th row has $2 \cdot i-1$ consecutive characters $\texttt{1}$ , and the central 1s are located in one column. An upside down triangle is also considered a valid triangle (but not rotated by 90 degrees).
 Two left pictures contain examples of triangles: $k=4$ , $k=3$ . The two right pictures don't contain triangles.- A square is a shape consisting of $k$ ( $k>1$ ) consecutive rows, where the $i$ -th row has $k$ consecutive characters $\texttt{1}$ , which are positioned at an equal distance from the left edge of the grid.
 Examples of two squares: $k=2$ , $k=4$ .For the given grid, determine the type of shape that is drawn on it.
- A triangle is a shape consisting of $k$ ( $k>1$ ) consecutive rows, where the $i$ -th row has $2 \cdot i-1$ consecutive characters $\texttt{1}$ , and the central 1s are located in one column. An upside down triangle is also considered a valid triangle (but not rotated by 90 degrees).
 Two left pictures contain examples of triangles: $k=4$ , $k=3$ . The two right pictures don't contain triangles.- A square is a shape consisting of $k$ ( $k>1$ ) consecutive rows, where the $i$ -th row has $k$ consecutive characters $\texttt{1}$ , which are positioned at an equal distance from the left edge of the grid.
 Examples of two squares: $k=2$ , $k=4$ .For the given grid, determine the type of shape that is drawn on it.
输入格式
The first line contains a single integer $t$ ( $1 \leq t \leq 100$ ) — the number of test cases.
The first line of each test case contains a single integer $n$ ( $2 \leq n \leq 10$ ) — the size of the grid.
The next $n$ lines each contain $n$ characters $\texttt{0}$ or $\texttt{1}$ .
The grid contains exactly one triangle or exactly one square that contains all the $\texttt{1}$ s in the grid. It is guaranteed that the size of the triangle or square is greater than $1$ (i.e., the shape cannot consist of exactly one 1).
The first line of each test case contains a single integer $n$ ( $2 \leq n \leq 10$ ) — the size of the grid.
The next $n$ lines each contain $n$ characters $\texttt{0}$ or $\texttt{1}$ .
The grid contains exactly one triangle or exactly one square that contains all the $\texttt{1}$ s in the grid. It is guaranteed that the size of the triangle or square is greater than $1$ (i.e., the shape cannot consist of exactly one 1).
输出格式
For each test case, output "SQUARE" if all the $\texttt{1}$ s in the grid form a square, and "TRIANGLE" otherwise (without quotes).
输入输出样例
输入 #1
6 3 000 011 011 4 0000 0000 0100 1110 2 11 11 5 00111 00010 00000 00000 00000 10 0000000000 0000000000 0000000000 0000000000 0000000000 1111111110 0111111100 0011111000 0001110000 0000100000 3 111 111 111
输出 #1
SQUARE TRIANGLE SQUARE TRIANGLE TRIANGLE SQUARE
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted