Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: eefirefire

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-05 19:45:26

#include <iostream>
using namespace std;

int main()
{
    string word, word2;
    cin >> word >> word2;

    int a1 = 0;
    int b1 = 0;
    int c1 = 0;
    int d1 = 0;
    int e1 = 0;
    int f1 = 0;
    int g1 = 0;
    int h1 = 0;
    
    for (char i : word)
    {
        if (i == 'A')
        {
            a1++;
        }
        if (i == 'B')
        {
            b1++;
        }
        if (i == 'C')
        {
            c1++;
        }
        if (i == 'D')
        {
            d1++;
        }
        if (i == 'E')
        {
            e1++;
        }
        if (i == 'F')
        {
            f1++;
        }
        if (i == 'G')
        {
            g1++;
        }
        if (i == 'H')
        {
            h1++;
        }
    }

    std::cout << a1 << " " << b1 << " " << c1 << " " << d1 << " " << e1 << " " << f1 << " " << g1 << " " << h1 << "\n";



    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    int e = 0;
    int f = 0;
    int g = 0;
    int h = 0;
    
    for (char i : word2)
    {
        if (i == 'A')
        {
            a++;
        }
        if (i == 'B')
        {
            b++;
        }
        if (i == 'C')
        {
            c++;
        }
        if (i == 'D')
        {
            d++;
        }
        if (i == 'E')
        {
            e++;
        }
        if (i == 'F')
        {
            f++;
        }
        if (i == 'G')
        {
            g++;
        }
        if (i == 'H')
        {
            h++;
        }
    }

    std::cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << "\n";

    std::cout << abs(a - a1) << " " << abs(b - b1) << " " << abs(c - c1) << " " << abs(d - d1) << " " << abs(e - e1) << " " << abs(f - f1) << " " << abs(g - g1) << " " << abs(h - h1) << "\n";

    int difference = abs(a - a1) + abs(b - b1) + abs(c - c1) + abs(d - d1) + abs(e - e1) + abs(f - f1) + abs(g - g1) +abs(h - h1);

    if (difference <= 3){
        cout << "anagram";
    } else{
        cout << "no";
    }
}