早教吧 育儿知识 作业答案 考试题库 百科 知识分享

英语翻译Sincetodayissospecial,ZOJwouldonlyacceptaspecialkindofstringstopassitstests.TheACrulesaregivenasthefollowing:1.thereareonlythreedistinctcapitallettersofthestrings:Z,O,andJ;2.anystringthatisintheform

题目详情
英语翻译
Since today is so special,ZOJ would only accept a special kind of strings to pass its tests.The AC rules are given as the following:
1.there are only three distinct capital letters of the strings:Z,O,and J;
2.any string that is in the form xZOJxO is acceptable,where x is a string either empty or composed of O's only;
3.if aZbJc is acceptable,then aZbOJcO is acceptable,where a,b and c are all strings either empty or composed of O's only.
Now it is your job to write a special judge program to tell if an input string is an AC string.
Input
The input consists of multiple test cases,each occupies a line containing the input string with length greater than 1 and less than 100.The string consists of only 'Z','O',and 'J'.Proceed until the end of file.
Output
For each test case,print in a line "Accepted" if the string is acceptable,or "Wrong Answer" if not.
Sample Input
ZOJO
OZOJOO
OZOOJOOO
OZOZOJOO
OOZOOJO
Sample Output
Accepted
Accepted
Accepted
Wrong Answer
Wrong Answer
▼优质解答
答案和解析
由于今天是如此特殊,ZOJ将只接受一种特殊的字符串通过其测试.给出的交流规则如下:
1.只有3个不同的大写字母的字符串:ž,澳,和J;
2.任何字符串的形式xZOJxO是可以接受,其中x是一个字符串或者空或由O的使用;
3.如果aZbJc是可以接受的,那么aZbOJcO是可以接受的,其中A,B和C都是字符串或空或O的唯一组成.
现在是你的工作写一个特别程序来告诉法官,如果输入的字符串是一个交流的字符串.
输入
输入多个测试案例组成,每行包含一个占地不到的长度大于1的输入字符串100.该字符串只包含的'Z','澳'和'J'来.继续,直到文件结尾.
产量
对于每个测试用例,打印行“接受”,如果字符串是可以接受的,或“错误的答案”,如果没有.
样本输入
增上
OZOJOO
OZOOJOOO
OZOZOJOO
OOZOOJO
示例输出
公认
公认
公认
错误的答案
错误的答案