HDU 3788 and 9du OJ 1006 test data are different, hduoj

Source: Internet
Author: User

HDU 3788 and 9du OJ 1006 test data are different, hduoj
ZOJ ProblemsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 2935 Accepted Submission (s): 889


Problem Description determines whether a given string (only contains 'Z', 'O', and 'J') can be AC.

The AC rules are as follows:
1. zoj can communicate with each other;
2. If the string format is xzojx, it can also be AC, where x can be N 'O' or is empty;
3. If azbjc can be AC, azbojac can also be AC, where a, B, and c are N 'O' or empty;
The Input contains multiple groups of test cases. Each line has a string that only contains 'Z', 'O', and 'J'. the string length is less than or equal to 1000;
Output outputs the string "Accepted" if it can be an AC string. Otherwise, Output "Wrong Answer ".
Sample Input

zojozojoozoojoooozoojoooozoojozojooooozojozojoooo
 
Sample Output
AcceptedAcceptedAcceptedAcceptedAcceptedAcceptedWrong AnswerWrong Answer
 


# Include <stdio. h> # include <string. h> char s [2001]; char s2 [2001]; void check () {int cnt = 0; memset (s2, 0, sizeof (s2); int flag1, flag2, flag3; flag1 = flag2 = flag3 =-1; int len = strlen (s); if (strcmp ("zoj", s) = 0) {printf ("Accepted \ n"); return;} else {for (int I = 0; I <len; ++ I) {if (s [I]! = 'Z' & s [I]! = 'O' & s [I]! = 'J') {flag3 = 1; break ;}} for (int I = 0; I <len; ++ I) {if (s [I] = 'Z') {flag1 = I; break;} for (int I = len-1; I> = 0; -- I) {if (s [I] = 'J') {flag2 = I; break ;}} if (flag1> flag2 | flag1 =-1 | flag2 =-1 | flag3 = 1) {printf ("Wrong Answer \ n ");} else {for (int I = flag1 + 1; I <flag2; I ++) {if (s [I] = 'O') {cnt ++ ;} // count the number of z and j intermediate o} if (cnt! = Flag2-flag1-1 | cnt = 0) {// judge whether any character except o exists in the middle of z and j; cnt = 0 is the zoj center without o, illegal; printf ("Wrong Answer \ n ");} else {// Number of o after j divided by the number of o before z equal to the number of o between z and j if (flag1 * cnt = len-flag2-1) {printf ("Accepted \ n");} else {printf ("Wrong Answer \ n") ;}}} int main (int argc, char * argv []) {while (~ Scanf ("% s", s) {check ();} return 0 ;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.