2 shunfurh shunfurh 于 2017.09.19 12:04 提问

Chat Rooms

Description

Suppose there are a number of good users using an Internet chat room, which is a shared text chat space. Now there are some bad guys in the Internet who would come to this room and would have no respect or interest in the topic of discussion in the group. They would start typing strings of garbage characters, start unsolicited advertisements of certain URLs or businesses, or paste same string again and again just to disturb others in the room.

When I asked about this problem to Prof Banku (naturally not as smart as Prof Shanku) he suggested the following scheme. Let us define consonants to be all letters in a-z and A-Z except a, e, i, o, u, y, A, E, I, O, U and Y.

A user should be able to send a line to the chat room unless

  • the line has more than 5 consecutive consonants, or

  • the line contains at least one word which has more than 4 consecutive consonants and the user sent more than 2 such lines in last 10 lines sent, or

  • the user sent the same line more than once in last 10 sentences sent.
    Input

Input consists of several lines. The first line contains an integer n, which is the number of lines in the shared text space. Then follow n lines each consisting of not more than 255 ASCII characters.
Output

For each line of input print y if the line is acceptable according to the criteria set above and n otherwise in separate lines. See the sample output for example.
Sample Input

12
hello
how r u?
where r u from?
kjhh kh kgkjhg jhg
where r u from?
i am from London, Ontario, Canada
how r you nxw?
now
where r u from?
kjhh kh kgkjhg jhg
very good
it is very cold here.
Sample Output

y
y
y
n
y
y
y
y
n
n
y
y

1个回答

devmiao
devmiao   Ds   Rxr 2017.10.04 09:21
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
[LeetCode] 841. Keys and Rooms
题目描述 There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, …, N-1, and each room may have some keys to access the next room. Formally, each room i has a list of ke...
LeetCode 253. Meeting Rooms II(会议室)
原题网址:https://leetcode.com/problems/meeting-rooms-ii/ Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of confe
【DFS】841. Keys and Rooms
class Solution { public: void dfs(int pos,vector&amp;lt;bool&amp;gt; &amp;amp;flag,vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt;&amp;amp; rooms) { flag[pos]=true; for(int i = 0;i&amp;lt;rooms[pos].size();i++) ...
[LeetCode 253] Meeting Rooms II
Given an array of meeting time intervals consisting of start and end times [[s1,e1], [s2,e2],...] (si  For example, Given [[0, 30],[5, 10],[15, 20]], return 2. solution: put start and nega
[LeetCode 253] Meeting Rooms II 扫描线的应用(Python)
扫描线的思想很巧妙,适用于一些一维算法问题的解决。这些问题涉及具有头尾节点的排序问题,单纯的对节点排序并不能很好的解决问题。扫描线应用的简单例子如LeetCode 253 Given an array of meeting time intervals consisting of start and end times [[s1,e1], [s2,e2],…] (si < ei)
【LeetCode】841. Keys and Rooms 解题报告(Python)
【LeetCode】841. Keys and Rooms 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/keys-and-rooms/description/ 题目描述: There are N rooms and you start in room 0. Each room has a d...
Leetcode: Meeting Rooms
QuestionGiven an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],…] (si < ei), determine if a person could attend all meetings.For example, Given [[0, 30],[5, 10],[1
LeetCode 841 题解
841. Keys and Rooms 题目大意:给你n个房间,每个房间里有一些钥匙,你在房间0,问能不能去到所有的房间。 解题思路:直接搜索一下就好了
Leetcode——841. Keys and Rooms
题目原址 https://leetcode.com/problems/keys-and-rooms/description/ 解题思路 经典DFS题 AC代码 class Solution { public boolean canVisitAllRooms(List&amp;lt;List&amp;lt;Integer&amp;gt;&amp;gt; rooms) { boolean[] r...
[LeetCode]Meeting Rooms II
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],…] (si < ei), find the minimum number of conference rooms required. For example, Given [[0, 30],[5