#pragma once

void initialise(char arr[], int size[], int n)
{
    for (int i = 0; i < n; i++)
    {
        arr[i] = (char)(i + 97);
        size[i] = 1;
    }
}

char find(char arr[], char a)
{
    if (a != arr[(int)a - 97])
        arr[(int)a - 97] = find(arr, arr[(int)a - 97]);
    return a;
}

bool root(char arr[], char a, char b)
{
    if (find(arr, a) == find(arr, b))
    {
        return true;
    }
    return false;
}


void combine(char arr[], int size[], char a, char b)
{
    char rootA = find(arr, a);
    char rootB = find(arr, b);
    if (size[(int)rootA - 97] < size[(int)rootB - 97])
    {
        arr[(int)rootA - 97] = rootB;
        size[(int)rootB - 97] += size[(int)rootA - 97];
    }
    else
    {
        arr[(int)rootB - 97] = rootA;
        size[(int)rootA - 97] += size[(int)rootB - 97];
    }
}