UVA 644 - Immediate Decodability

枚举。

第一次遇见:

Your submission with number ***** for the problem 644 - Immediate Decodability has failed with verdict .

/*

    644 - Immediate Decodability

*/

# include <cstdio>

# include <cstring>



int n;

char s[10][15];



bool in(char *p, char *t)

{

    for (int i = 0; p[i]; ++i)

        if (!t[i] || p[i] != t[i]) return false;

    return true;

}



int main()

{

    freopen("in.txt", "r", stdin);

    freopen("out.txt", "w", stdout);

    

    int T = 0;

    n = 0;

    while (~scanf("%s", s[n]))

    {

        while (strcmp(s[n], "9"))

            scanf("%s", s[++n]);

        printf("Set %d", ++T);

        bool ok = true;

        for (int i = 0; i < n; ++i)

        for (int j = i+1; j < n; ++j)

        {

            if (in(s[i], s[j]) || in(s[j], s[i]))

            {

                ok = false;

                break;

            }

        }

        n = 0;

        puts(ok ? " is immediately decodable":

                  " is not immediately decodable");

    }

    

    return 0;

}

/**/

你可能感兴趣的:(media)