A16097 | Gift Carpet
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Recently, Tema and Vika celebrated Family Day. Their friend Arina gave them a carpet, which can be represented as an $n \cdot m$ table of lowercase Latin letters.
Vika hasn't seen the gift yet, but Tema knows what kind of carpets she likes. Vika will like the carpet if she can read her name on. She reads column by column from left to right and chooses one or zero letters from current column.
Formally, the girl will like the carpet if it is possible to select four distinct columns in order from left to right such that the first column contains "v", the second one contains "i", the third one contains "k", and the fourth one contains "a".
Help Tema understand in advance whether Vika will like Arina's gift.
Vika hasn't seen the gift yet, but Tema knows what kind of carpets she likes. Vika will like the carpet if she can read her name on. She reads column by column from left to right and chooses one or zero letters from current column.
Formally, the girl will like the carpet if it is possible to select four distinct columns in order from left to right such that the first column contains "v", the second one contains "i", the third one contains "k", and the fourth one contains "a".
Help Tema understand in advance whether Vika will like Arina's gift.
输入格式
Each test consists of multiple test cases. The first line of input contains a single integer $t$ ( $1 \le t \le 100$ ) — the number of test cases. Then follows the description of the test cases.
The first line of each test case contains two integers $n$ , $m$ ( $1 \le n, m \le 20$ ) — the sizes of the carpet.
The next $n$ lines contain $m$ lowercase Latin letters each, describing the given carpet.
The first line of each test case contains two integers $n$ , $m$ ( $1 \le n, m \le 20$ ) — the sizes of the carpet.
The next $n$ lines contain $m$ lowercase Latin letters each, describing the given carpet.
输出格式
For each set of input data, output "YES" if Vika will like the carpet, otherwise output "NO".
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
输入输出样例
输入 #1
5 1 4 vika 3 3 bad car pet 4 4 vvvv iiii kkkk aaaa 4 4 vkak iiai avvk viaa 4 7 vbickda vbickda vbickda vbickda
输出 #1
YES NO YES NO YES
In the first sample, Vika can read her name from left to right.
In the second sample, Vika cannot read the character "v", so she will not like the carpet.
In the second sample, Vika cannot read the character "v", so she will not like the carpet.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted