Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Newton4566

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.004 second

Submitted On: 2026-09-25 15:25:50

#include <iostream>
using namespace std;


int main() {
    string a, b;
    cin >> a >> b;

    int countA[8] = {0};
    int countB[8] = {0};
    int dif[8] = {0};

    for (char c : a) {
        countA[c - 'A'] += 1;
    }

    for (char c : b) {
        countB[c - 'A'] += 1;
    }

    int sum = 0;

    for (int i = 0; i < 8; i++) {
        dif[i] = abs(countA[i] - countB[i]);
        sum += dif[i];
    }

    for (int n : countA) {
        cout << n << ' ';
    }
    cout << endl;

    for (int n : countB) {
        cout << n << ' ';
    }
    cout << endl;

    for (int n : dif) {
        cout << n << ' ';
    }
    cout << endl;

    if (sum > 3) {
        cout << "no" << endl;
    } else {
        cout << "anagram" << endl;
    }

    return 0;
}