Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: cyblox_boi

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-22 22:57:13

#include <cmath>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	vector<string> words(2);
	vector<map<char, int>> countAlphabet(2);

	for (int i = 0; i < 2; i++) {
		cin >> words[i];

		for (const char &ch : words[i]) {
			countAlphabet[i][ch]++;
		}
	}

	for (int i = 0; i < 2; i++) {
		for (char j = 'A'; j <= 'H'; j++) {
			cout << countAlphabet[i][j] << ' ';
		}

		cout << '\n';
	}

	int countDifferent = 0;

	for (char i = 'A'; i <= 'H'; i++) {
		int result = abs(countAlphabet[0][i] - countAlphabet[1][i]);
		countDifferent += result;

		cout << result << ' ';
	}

	cout << '\n';

	if (countDifferent > 3) {
		cout << "no";
	} else {
		cout << "anagram";
	}

	cout << '\n';

	return 0;
}