Submission

Status:

PPPPPPPP-P

Subtask/Task Score:

90/100

Score: 90

User: APNICHANAN

Problemset: อะนาแกรม 2

Language: c

Time: 0.001 second

Submitted On: 2025-09-27 13:28:43

#include <stdio.h>
#include <string.h>
int main()
{
    char str[2][10000];
    scanf("%s %s", str[0], str[1]);
    int a[2] = {0, 0}, b[2] = {0, 0}, c[2] = {0, 0}, d[2] = {0, 0}, e[2] = {0, 0}, f[2] = {0, 0}, g[2] = {0, 0}, h[2] = {0, 0}, cnt = 0;
    for (int j = 0; j < strlen(str[0]); j++)
    {
        if (str[0][j] == 'A')
            a[0]++;
        else if (str[0][j] == 'B')
            b[0]++;
        else if (str[0][j] == 'C')
            c[0]++;
        else if (str[0][j] == 'D')
            d[0]++;
        else if (str[0][j] == 'E')
            e[0]++;
        else if (str[0][j] == 'F')
            f[0]++;
        else if (str[0][j] == 'G')
            g[0]++;
        else if (str[0][j] == 'H')
            h[0]++;
    }
    printf("%d %d %d %d %d %d %d %d", a[0], b[0], c[0], d[0], e[0], f[0], g[0], h[0]);
    printf("\n");
    for (int j = 0; j < strlen(str[1]); j++)
    {
        if (str[1][j] == 'A')
            a[1]++;
        else if (str[1][j] == 'B')
            b[1]++;
        else if (str[1][j] == 'C')
            c[1]++;
        else if (str[1][j] == 'D')
            d[1]++;
        else if (str[1][j] == 'E')
            e[1]++;
        else if (str[1][j] == 'F')
            f[1]++;
        else if (str[1][j] == 'G')
            g[1]++;
        else if (str[1][j] == 'H')
            h[1]++;
    }
    printf("%d %d %d %d %d %d %d %d", a[1], b[1], c[1], d[1], e[1], f[1], g[1], h[1]);
    printf("\n");
    if (a[0] != a[1])
    {
        printf("1 ");
        cnt++;
    }
    else
    {
        printf("0 ");
    }
    if (b[0] != b[1])
    {
        printf("1 ");
        cnt++;
    }
    else
    {
        printf("0 ");
    }
    if (c[0] != c[1])
    {
        printf("1 ");
        cnt++;
    }
    else
    {
        printf("0 ");
    }
    if (d[0] != d[1])
    {
        printf("1 ");
        cnt++;
    }
    else
    {
        printf("0 ");
    }
    if (e[0] != e[1])
    {
        printf("1 ");
        cnt++;
    }
    else
    {
        printf("0 ");
    }
    if (f[0] != f[1])
    {
        printf("1 ");
        cnt++;
    }
    else
    {
        printf("0 ");
    }
    if (g[0] != g[1])
    {
        printf("1 ");
        cnt++;
    }
    else
    {
        printf("0 ");
    }
    if (h[0] != h[1])
    {
        printf("1 ");
        cnt++;
    }
    else
    {
        printf("0 ");
    }
    printf("\n");
    if (cnt > 3)
        printf("no");
    else
        printf("anagram");
}