HDU 3788 zoj问题

                 ZOJ问题

Problem Description

对给定的字符串(只包含‘z‘,‘o‘,‘j‘三种字符),判断他是否能AC。

是否AC的规则如下:
1. zoj能AC;
2. 若字符串形式为xzojx,则也能AC,其中x可以是N个‘o‘ 或者为空;
3. 若azbjc 能AC,则azbojac也能AC,其中a,b,c为N个‘o‘或者为空;

Input

输入包含多组测试用例,每行有一个只包含‘z‘,‘o‘,‘j‘三种字符的字符串,字符串长度小于等于1000;

Output

对于给定的字符串,如果能AC则请输出字符串“Accepted”,否则请输出“Wrong Answer”。

Sample Input

zoj

ozojo

ozoojoo

oozoojoooo

zooj

ozojo

oooozojo

zojoooo

Sample Output

Accepted

Accepted

Accepted

Accepted

Accepted

Accepted

Wrong Answer

Wrong Answer

就是前面的o的个数乘以中间o的个数等于后面o的个数,并保证o的个数不为0且"z","j"的个数只有一个.

代码:

 1 #include<cstdio>
 2 #include<cstring>
 3 using namespace std;
 4
 5 int main()
 6 {
 7     char s[1005];
 8     int i,j;
 9     int count1,count2,count3;
10     while(scanf("%s",s)!=EOF)
11     {
12         count3=count1=count2=0;
13         int len=strlen(s);
14         for(i=0;i<len;i++)
15         if(s[i]==‘z‘)count1++;
16         else if(s[i]==‘j‘)count2++;
17         else count3++;
18         if(count1!=1||count2!=1||count3==0)
19         {
20             printf("Wrong Answer\n");
21             continue;
22         }
23         for(i=0;i<len;i++)
24         if(s[i]==‘z‘)break;
25         for(j=len-1;j>=0;j--)
26         if(s[j]==‘j‘)break;
27         if(i*(j-i-1)==len-j-1)
28         printf("Accepted\n");
29         else
30         printf("Wrong Answer\n");
31     }
32     return 0;
33 }
时间: 2024-12-18 23:56:40

HDU 3788 zoj问题的相关文章

hdu 3788 ZOJ问题 (字符串)

ZOJ问题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2881    Accepted Submission(s): 866 Problem Description 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC. 是否AC的规则如下: 1. zoj能AC: 2. 若字符串形式为xzojx,则也能AC,其

HDU 1986 &amp; ZOJ 2989 Encoding(模拟)

题目链接: HDU: http://acm.hdu.edu.cn/showproblem.php?pid=1986 ZOJ: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1988 HDU 1987 & ZOJ 2990 和这题刚好相反,也是比较容易模拟: Chip and Dale have devised an encryption method to hide their (written) text messages

HDU 4791 &amp; ZOJ 3726 Alice&#39;s Print Service (数学 打表)

题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5072 Problem Description Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her pr

HDU 4430 &amp; ZOJ 3665 Yukari&#39;s Birthday(二分+枚举)

题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4430 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4888 Problem Description Today is Yukari's n-th birthday. Ran and Chen hold a celebration party for her. Now comes the most import

POJ1607 &amp; HDU 1330 &amp; ZOJ 1216 Deck(数学题)

题目链接: POJ  1607 : http://poj.org/problem?id=1607 HDU 1330 :http://acm.hdu.edu.cn/showproblem.php?pid=1330 ZOJ  1216 : Description A single playing card can be placed on a table, carefully, so that the short edges of the card are parallel to the table

HDU 1242 &amp;&amp; ZOJ 1649( BFS (队列 || 优先队列)).

~~~~ 突然发现一篇搜索的题目都有写.昨天发现道bfs题目,HDU上AC, ZOJ上WA.不得不说HDU上的数据之水.. 今天早起刷题有了思路,并用队列和单调队列都写了一遍,0MS飘过~~ ~~~~ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1242 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=649 ~~~~ 首先有坑的地方是friends,对嘛,朋友有很多,ang

HDU 2377 &amp;&amp; ZOJ 2412

~~~~ 输入好长... 思路就是对线路上的每一个点BFS记录各个点到其所需的star值,然后ans记录所需的最大star值,最后输出ans最小的star值及相应的id. 开始建链接矩阵,结果MLE,于是修改了下. 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2377 http://acm.zju.edu.cn/onlinejudge/showProblemStatus.do?problemId=1912 ~~~~ #include<iostr

图论 500题——主要为hdu/poj/zoj

转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i

HDU 1988 &amp; ZOJ 2991 Flipping Burned Pancakes(数学啊+模拟)

题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1988 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1990 Problem Description The cook at the Frobbozz Magic Pancake House sometimes falls asleep on the job while cooking pancakes. As