LightOJ-1051 good or bad (scan)

Source: Internet
Author: User
Tags cas mixed printf

Title: Give you a string, if there are three adjacent consonants, or three adjacent original letters, the string is bad, and vice versa is good. There are in the string. , allowing the. into any of the 26 letters. If the string can change to bad and good, then the output mixed

Problem-solving ideas: Do not consider first. To see if it's bad, and if it's bad, you don't have to think about it.
Think about everything again. Become a cause and a consonant in two cases, see if it turns bad
Finally, consider whether it is always bad, if not always, it means that the string can be changed good
Judging whether it is bad forever, just judge it? No matter how bad it's going to be.

#include <cstdio> #include <cstring> const int N = 60;
Char Str[n];

int len, cas = 1;
    void Init () {scanf ("%s", str);
len = strlen (str);
    } void Solve () {int vow = 0, con = 0;
    BOOL Bad = 0, good = 0, Allbad = 0; for (int i = 0; i < len; i++) {if (str[i] = = ' A ' | | str[i] = = ' E ' | | str[i] = = ' I ' | | str[i] = = ' O ' | | str[i]
            = = ' U ') {vow++;
        con = 0; } else if (str[i] = = '? ')
            {vow = 0;
        con = 0;
            } else {con++;
        Vow = 0;
            } if (vow = = 3 | | con = = 5) {Allbad = bad = 1;
        Break
        }} if (Allbad) {printf ("Case%d:bad\n", cas++);
    return;
        } if (!bad) {vow = 0, con = 0; for (int i = 0; i < len; i++) {if (str[i] = = ' A ' | | str[i] = = ' E ' | | str[i] = = ' I ' | | str[i] = = ' O ' | | | str [i] = = ' U ' | | Str[i] = = '? ')
       {vow++;         con = 0;
                } else {vow = 0;
            con++;
                } if (vow = = 3) {bad = true;
            Break
        }}} if (!bad) {vow = 0, con = 0; for (int i = 0; i < len; i++) {if (str[i] = = ' A ' | | str[i] = = ' E ' | | str[i] = = ' I ' | | str[i] = = ' O ' | | | str
                [i] = = ' U ') {vow++;
            con = 0;
                } else {con++;
            Vow = 0;
                } if (con = = 5) {bad = true;
            Break }}} for (int i = 0; i < len; i++) {if (str[i] = = '? ')
            {int leftvow = 0, Leftcon = 0, rightvow = 0, Rightcon = 0;
                for (int j = i-1; J >= 0, j--) {if (str[j] = = '? ') break;
   if (str[j] = = ' A ' | | str[j] = = ' E ' | | str[j] = = ' I ' | | str[j] = = ' O ' | | str[j] = = ' U ') {                 if (Leftcon) break;
                leftvow++;
                    } else {if (leftvow) break;
                leftcon++;
                }} for (int j = i + 1, j < Len; J + +) {if (str[j] = = '? ') break; if (str[j] = = ' A ' | | str[j] = = ' E ' | | str[j] = = ' I ' | | str[j] = = ' O ' | | str[j] = = ' U ') {if (rig
                    Htcon) break;
                rightvow++;
                    } else {if (rightvow) break;
                rightcon++; }} if ((Leftvow = = 2 && Rightcon = = 4) | | (Leftcon = = 4 && rightvow = = 2))
            Allbad = 1;
            if (leftvow = = 2 | | rightvow = = 2) str[i] = ' Q ';
            if (Leftcon = = 4 | | rightcon = = 4) str[i] = ' A ';
        if (Allbad) break;
    }} if (Allbad) printf ("Case%d:bad\n", cas++); else if (bad) printf (' Case%d:miXed\n ", cas++);
else if (!bad) printf ("Case%d:good\n", cas++);
    } int main () {int test;
    scanf ("%d", &test);
        while (test--) {init ();
    Solve ();
} 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.