Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: tonkla

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-06 21:59:09

#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	string x;
	int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;
	cin>> x;
	for (int i =0;i<x.length();i++){
		if(x[i]=='A'){
			a++;
		}
		if(x[i]=='B'){
			b++;
		}
		if(x[i]=='C'){
			c++;
		}
		if(x[i]=='D'){
			d++;
		}
		if(x[i]=='E'){
			e++;
		}
		if(x[i]=='F'){
			f++;
		}
		if(x[i]=='G'){
			g++;
		}
		if(x[i]=='H'){
			h++;
		}
		
}

	
	//x2
	string x2;
	int a1=0,b1=0,c1=0,d1=0,e1=0,f1=0,g1=0,h1=0;
	cin>> x2;
	for (int i =0;i<x2.length();i++){
		if(x2[i]=='A'){
			a1++;
		}
		if(x2[i]=='B'){
			b1++;
		}
		if(x2[i]=='C'){
			c1++;
		}
		if(x2[i]=='D'){
			d1++;
		}
		if(x2[i]=='E'){
			e1++;
		}
		if(x2[i]=='F'){
			f1++;
		}
		if(x2[i]=='G'){
			g1++;
		}
		if(x2[i]=='H'){
			h1++;
		}
		
}
	cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<" "<<g<<" "<<h<<"\n";
	cout<<a1<<" "<<b1<<" "<<c1<<" "<<d1<<" "<<e1<<" "<<f1<<" "<<g1<<" "<<h1<<"\n";
	cout<<abs(a-a1)<<" "<<abs(b-b1)<<" "<<abs(c-c1)<<" "<<abs(d-d1)<<" "<<abs(e-e1)<<" "<<abs(f-f1)<<" "<<abs(g-g1)<<" "<<abs(h-h1)<<" "<<"\n";
	if (abs(a-a1)+abs(b-b1)+abs(c-c1)+abs(d-d1)+abs(e-e1)+abs(f-f1)+abs(g-g1)+abs(h-h1)<=3){
		cout<<"anagram";
	}
	else{
		cout<<"no";
	}
}