HDU 3788 and nine degrees OJ 1006 test data is not the same

Source: Internet
Author: User

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 The given string (including only ' Z ', ' o ', ' J ' three characters) to infer if he can AC.

Whether the rules of the AC are for example the following:
1. Zoj can ac;
2. If the string form is XZOJX, it can also be AC, where x can be n ' o ' or null;
3. If the AZBJC can be AC, the Azbojac can also be AC. The a,b,c is n ' o ' or empty;
Input inputs include multiple sets of test cases, each with a string that contains only ' Z ', ' o ', ' J ' three characters, and the string length is less than or equal to 1000.
Output for the given string, assuming that you can AC, please export the string "Accepted", 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++; }//Statistics Z, j the number of Middle O} if (cnt!=flag2-flag1-1| | cnt==0) {//infer whether characters except o appear in the middle of Z and J. Cnt=0 is the middle of Zoj does not appear o.                 Not legal.             printf ("Wrong answer\n");                     } else{the number of O after//j divided by the number of O in front of Z equals 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;}


Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

HDU 3788 and nine degrees OJ 1006 test data is not the same

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.