Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: code

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.002 second

Submitted On: 2025-12-06 18:27:53

#include <bits/stdc++.h>
using namespace std;
int main(){
    string word1;cin>>word1;
    string word2;cin>>word2;
    vector <int> cnt1(8,0);
    vector <int> cnt2(8,0);
    for (int i=0;i<word1.length();i++){
        cnt1[int(word1[i])-65]+=1;
    }
    for (int i=0;i<word2.length();i++){
        cnt2[int(word2[i])-65]+=1;
    }
    for (int i=0;i<8;i++){
        cout<<cnt1[i]<<" ";
    }
    cout<<endl;
    for (int i=0;i<8;i++){
        cout<<cnt2[i]<<" ";
    }
    cout<<endl;
    int wrong=0,n;
    for (int i=0;i<8;i++){
        if (cnt1[i]>cnt2[i]){
            n=cnt1[i]-cnt2[i];
            cout<<n<<" ";
        }else{
            n=cnt2[i]-cnt1[i];
            cout<<n<<" ";
        }
        if (n!=0){
            wrong+=1;
        }
    }
    cout<<endl;
    if (wrong>3){
        cout<<"no";
    }else{
        cout<<"anagram";
    }
}