Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: loop

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.005 second

Submitted On: 2026-10-10 18:31:16

#include <iostream>
#include <string>
using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    int x[8] = {0}, y[8] = {0};
    for (int i = 0; i < (int)a.size(); i++) if (a[i] >= 'A' && a[i] <= 'H') x[a[i] - 'A']++;
    for (int i = 0; i < (int)b.size(); i++) if (b[i] >= 'A' && b[i] <= 'H') y[b[i] - 'A']++;
    int total = 0;
    for (int c = 0; c < 8; c++) cout << x[c] << (c < 7 ? ' ' : '\n');
    for (int c = 0; c < 8; c++) cout << y[c] << (c < 7 ? ' ' : '\n');
    for (int c = 0; c < 8; c++) {
        int d = x[c] > y[c] ? x[c] - y[c] : y[c] - x[c];
        total += d;
        cout << d << (c < 7 ? ' ' : '\n');
    }
    cout << (total <= 3 ? "anagram" : "no") << '\n';
    return 0;
}