Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: chs_14

Problemset: อะนาแกรม 2

Language: cpp

Time: 0.003 second

Submitted On: 2026-01-18 13:44:50

#include <bits/stdc++.h>
using namespace std;

vector<int> anagram1(8), anagram2(8), diff(8);

int main() {
    cin.tie(0)->sync_with_stdio();

    string str1, str2;
    cin >> str1 >> str2;

    for (char &c : str1)
    {
        ++anagram1[c-'A'];
    }
    for (char &c : str2)
    {
        ++anagram2[c-'A'];
    }
    for (int i = 0; i < 8; i++)
    {
        diff[i] = abs(anagram1[i]-anagram2[i]);
    }
    
    for (int &x : anagram1)
    {
        cout << x << ' ';
    }
    cout << '\n';
    for (int &x : anagram2)
    {
        cout << x << ' ';
    }
    cout << '\n';
    for (int &x : diff)
    {
        cout << x << ' ';
    }
    cout << '\n';

    for (int i = 1; i < 8; i++)
    {
        diff[i]+=diff[i-1];
    }
    if (diff[7]>3) {
        cout << "no";
    }
    else {
        cout << "anagram";
    }

    return 0;
}