Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Trin1506

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-12 12:44:57

#include <bits/stdc++.h>
using namespace std;
int main(){
    string word;
    string word2;
    cin >> word;
    cin >> word2;
    int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;
    int a2=0,b2=0,c2=0,d2=0,e2=0,f2=0,g2=0,h2=0;
    int cnt=0;
    for(int i=0;i<word.size();i++){
        if(word[i]=='A')a++;
        if(word[i]=='B')b++;
        if(word[i]=='C')c++;
        if(word[i]=='D')d++;
        if(word[i]=='E')e++;
        if(word[i]=='F')f++;
        if(word[i]=='G')g++;
        if(word[i]=='H')h++;
    }
    cout << a << " "<<b << " " << c << " "<< d << " "<<e<< " "<< f<<" "<<g<<" "<< h <<'\n';
    for(int i=0;i<word2.size();i++){
        if(word2[i]=='A')a2++;
        if(word2[i]=='B')b2++;
        if(word2[i]=='C')c2++;
        if(word2[i]=='D')d2++;
        if(word2[i]=='E')e2++;
        if(word2[i]=='F')f2++;
        if(word2[i]=='G')g2++;
        if(word2[i]=='H')h2++;
    }
    cout << a2 << " "<<b2 << " " << c2 << " "<< d2 << " "<<e2<< " "<< f2<<" "<<g2<<" "<< h2<<'\n';
    cout << abs(a2-a)<<" "<<abs(b2-b)<<" "<<abs(c2-c) << " "<< abs(d2-d) <<" "<< abs(e2-e) <<" "<< abs(f2-f) <<" "<< abs(g2-g) <<" "<< abs(h2-h) <<'\n';
    if(abs(a2-a)!=0)cnt++;
    if(abs(b2-b)!=0)cnt++;
    if(abs(c2-c)!=0)cnt++;
    if(abs(d2-d)!=0)cnt++;
    if(abs(e2-e)!=0)cnt++;
    if(abs(f2-f)!=0)cnt++;
    if(abs(g2-g)!=0)cnt++;
    if(abs(h2-h)!=0)cnt++;
    if(cnt>3)cout << "no";
    else cout << "anagram";

    }