Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: punzacp555

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-05 20:47:55

#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    string a, b;
    cin >> a >> b;

    int freq1[8], freq2[8];
    memset(freq1, 0, sizeof(freq1));
    memset(freq2, 0, sizeof(freq2));

    int difcnt = 0;

    for(int i=0; i<a.length(); i++) {
        freq1[a[i]-'A']++;
    }
    for(int i=0; i<b.length(); i++) {
        freq2[b[i]-'A']++;
    }

    for(int x : freq1) cout << x << ' ';
    cout << "\n";
    for(int x : freq2) cout << x << ' ';
    cout << "\n";
    for(int i=0; i<8; i++) {
        int dif = abs(freq1[i]-freq2[i]);
        if(dif) difcnt++;
        cout << dif << ' ';
    }
    cout << "\n" << (difcnt <= 3 ? "anagram" : "no");

    return 0;
}