Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: speed_coding

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.003 second

Submitted On: 2026-10-08 21:02:36

#include<bits/stdc++.h>
using namespace std;
int main(){
	string str1 , str2;
	cin >> str1 >> str2 ;
	int count1[8] = {0} ;
	int count2[8] = {0} ;
	int diff[8] = {0} ;
	int total_diff = 0;
	for(int i = 0; i < str1.length(); i++){
		char c = str1[i] ;
		count1[c - 'A']++;
	}
	for(int i = 0; i < str2.length(); i++){
		char c = str2[i] ;
		count2[c - 'A']++;
	}
	for(int i = 0; i < 8; i++){
		diff[i] = abs(count1[i] - count2[i]) ;
		total_diff += diff[i] ;
	}
	for(int i = 0; i < 8 ; i++){
	    cout << count1[i] << (i == 7 ? "\n" : " "); 
	}
	for(int i = 0; i < 8 ; i++){
	    cout << count2[i] << (i == 7 ? "\n" : " "); 
	}
	for(int i = 0; i < 8 ; i++){
	    cout << diff[i] << (i == 7 ? "\n" : " "); 
	}
	if(total_diff <= 3){
		cout << "anagram\n" ;
	}
	else{
		cout << "no\n" ;
	}
}