Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: polikanta

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.002 second

Submitted On: 2026-09-27 19:56:54

#include<iostream>
using namespace std;
int main(){
    string str1, str2;
    cin >> str1 >> str2;
    int count1[8] = {0};
    int count2[8] = {0};
    for (char c : str1){
        count1[c - 'A']++;
    }
    for (char c : str2){
        count2[c - 'A']++;
    }
    for (int i = 0; i < 8; i++){
        cout << count1[i] << " ";
    }
    cout << "\n";
    for (int i = 0; i < 8; i++){
        cout << count2[i] << " ";
    }
    cout << "\n";
    int cdiff = 0;
    for(int i = 0; i < 8;i++){
        int diff = count1[i]-count2[i];
        if (diff < 0){
            diff = -diff;
        }
        cout << diff << " ";
        cdiff += diff;
    }
    cout << "\n";
    if(cdiff <= 3){
        cout << "anagram\n";
    }
    else{
        cout << "no\n";
    }
}