Nine degrees OJ 1006 Zoj problem (problem with the test data)

Source: Internet
Author: User
Tags time limit

Topic 1006:zoj Questions

Time limit: 1 seconds

Memory Limit: 32 MB

Special question: No

Submitted: 15725

Solution: 2647 Topic Description: for a given string (contains only ' z ', ' o ', ' J ' three characters), determine if he can AC.

The rules for AC are as follows:
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 AZBJC can AC, then Azbojac can also be AC, where a,b,c is n ' o ' or empty; input: input contains multiple sets of test cases, each line has a string containing only ' Z ', ' o ', ' J ' three characters, the string length is less than or equal to 1000. output: for a given string, if you can ac then please output the string "Accepted", otherwise output "wrong Answer". Sample Input:

Zoj
ozojo
ozoojoo
oozoojoooo
zooj
ozojo
oooozojo
zojoooo
Sample output:
Accepted
Accepted
Accepted
Accepted
Accepted
Accepted
wrong Answer
wrong Answer
In fact, the code that can be AC, the sample output is:


#include <stdio.h>
#include <string.h>
char s[1001];
int main ()
{
    int num1,num2,num3;
    char *p;
    while (scanf ("%s", s)!=eof)
    {
        NUM1 = num2 = num3 = 0;
        p = s;
        if (!strcmp ("Zoj", s)) {printf ("accepted\n"); continue;}
        while ((*p) = = ' O ') {num1++; p++;}
        if ((*p) = = ' Z ') {
            p++;
            while ((*p) = = ' O ') {num2++; p++;}
            if ((*p) = = ' J ') {
                p++;
                while ((*p) = = ' O ') {num3++; p++;}
                if (! ( *p) && num2>0 && num3==num1*num2) {printf ("accepted\n"); continue;}
            }
        }
        printf ("Wrong answer\n");
    }
    return 0;
}
 
/**************************************************************
    problem:1006
    user:kirchhoff
    Language:c
    result:accepted
    time:30 Ms
    memory:916 KB
**************************************** ************************/



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.