Submission
Status:
PPPPPPPP-P
Subtask/Task Score:
90/100
Score: 90
User: ztmy_
Problemset: อะนาแกรม 2
Language: cpp
Time: 0.003 second
Submitted On: 2025-10-12 14:27:44
#include <iostream>
using namespace std;
int main(){
string s1, s2;
cin >> s1;
cin >> s2;
int len1 = s1.length();
int len2 = s2.length();
int arr1[8] = {0};
int arr2[8] = {0};
int diff[8] = {0};
int sum = 0;
for (int i = 0; i < len1; i++){
int temp = s1[i] - 'A';
for (int j = 0; j < 8; j++){
if (temp == j) arr1[j]++;
}
}
for (int i = 0; i < len2; i++){
int temp = s2[i] - 'A';
for (int j = 0; j < 8; j++){
if (temp == j) arr2[j]++;
}
}
for (int i = 0; i < 8; i++){
if (arr1[i] != arr2[i]) {
diff[i]++;
sum += diff[i];
}
}
for (int i = 0; i < 8; i++) cout << arr1[i] << " ";
cout << endl;
for (int i = 0; i < 8; i++) cout << arr2[i] << " ";
cout << endl;
for (int i = 0; i < 8; i++) cout << diff[i] << " ";
cout << endl;
if (sum <= 3) cout << "anagram";
else cout << "no";
}