Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: lazy

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.003 second

Submitted On: 2025-10-15 09:01:22

#include <bits/stdc++.h>

using namespace std;

int main()
{

    string a,b;

    cin >> a >> b;

    map<char,int> A = {
        {'a',0},
        {'b',0},
        {'c',0},
        {'d',0},
        {'e',0},
        {'f',0},
        {'g',0},
        {'h',0},
    };
    map<char,int> B = A;

    for (int i = 0; i < a.length(); i++) {
        A[tolower(a[i])]++;
    }
    for (int i = 0; i < b.length(); i++) {
        B[tolower(b[i])]++;
    }


    for (const auto& pair : A) {
        cout << pair.second << " ";
    }
    cout << endl;
    for (const auto& pair : B) {
        cout << pair.second << " ";
    }
    cout << endl;

    int i = 0;
    int count = 0;
    for (const auto& pair : A) {
        int diff = abs(pair.second - B[pair.first]) ;
        cout << diff  << " ";
        count += diff;
    }

    if (count > 3) {
        cout << "\nno";
    } else {
        cout << "\nanagram";
    }
    return 0;
}