Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: korn234
Problemset: อะนาแกรม 2
Language: cpp
Time: 0.004 second
Submitted On: 2026-09-21 15:42:48
#include <iostream>
using namespace std;
int main(){
string a;
string b;
int countA[8]={0};
int countB[8]={0};
int countC[8]={0};
int d=0;
cin>>a>>b;
for (int i=0; i<a.length(); i++){
countA[a[i]-'A']++;
}
for (int i=0; i<b.length(); i++){
countB[b[i]-'A']++;
}
for (int i=0; i<8; i++){
cout<<countA[i]<<" ";
}
cout<<"\n";
for (int i=0; i<8; i++){
cout<<countB[i]<<" ";
}
for (int i=0; i<8; i++){
if (countA[i]>countB[i]){
countC[i]=countA[i]-countB[i];
}
else{
countC[i]=countB[i]-countA[i];
}
}
cout<<"\n";
for (int i=0; i<8; i++){
cout<<countC[i]<<" ";
}
for (int i=0; i<8; i++){
d+=countC[i];
}
cout<<"\n";
if (d<=3){
cout<<"anagram";
}
else{
cout<<"no";
}
}