Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: 666whynot
Problemset: อะนาแกรม 2
Language: cpp
Time: 0.003 second
Submitted On: 2025-08-09 20:51:57
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
string n,m;cin>>n>>m;
int a1=0,b1=0,c1=0,d1=0,e1=0,f1=0,g1=0,h1=0;
int a2=0,b2=0,c2=0,d2=0,e2=0,f2=0,g2=0,h2=0;
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;
for(char x:n){
if(x == 'A')a1++;
else if(x == 'B')b1++;
else if(x == 'C')c1++;
else if(x == 'D')d1++;
else if(x == 'E')e1++;
else if(x == 'F')f1++;
else if(x == 'G')g1++;
else h1++;
}
cout << a1 << ' ' << b1 << ' '<< c1 << ' '<< d1 << ' '<< e1 << ' '<< f1 << ' '<< g1 << ' ' << h1<<'\n';
for(char x:m){
if(x == 'A')a2++;
else if(x == 'B')b2++;
else if(x == 'C')c2++;
else if(x == 'D')d2++;
else if(x == 'E')e2++;
else if(x == 'F')f2++;
else if(x == 'G')g2++;
else h2++;
}
cout << a2 << ' ' << b2 << ' '<< c2 << ' '<< d2 << ' '<< e2 << ' '<< f2 << ' '<< g2 << ' ' << h2<<'\n';
a = abs(a1-a2);b = abs(b1-b2);c = abs(c1-c2);d = abs(d1-d2);e = abs(e1-e2);f = abs(f1-f2);g = abs(g1-g2);h = abs(h1-h2);
cout << a << ' ' << b << ' '<< c << ' '<< d << ' '<< e << ' '<< f << ' '<< g << ' ' << h<<'\n';
if(a+b+c+d+e+f+g+h <= 3)cout << "anagram";
else cout<<"no";
}