Kattis Challenge - Animal Classification
This isn't really what you're looking for, just some general feedback on your code.  I find the code quite difficult to follow, resolving some of the issues below to help with readability might make it more likely that you will get feedback that aimed at your algorithm.

Naming

Your names seem overly concise.  A few extra letters won't make any difference to the speed of your application, but make it a lot more readable.  Variables in main are n,x,y,c,A,B,i,c,tmp,t1,t2,res.  Without looking at the context, these names are meaningless.

Your mt method is similarly nondescript.  Perhaps make_tree might be more appropriate?

Consistent expecatations

In main, you reuse the variable name i for both an int and an unordered_set&lt;unordered_set&lt;int&gt;, hash_X&gt;.  Switching variable types like this makes your code harder to follow than necessary and illustrates that you could benefit from more meaningful names.

Indentation

Your indentation is all over the place.  This makes it difficult to read.  Sometimes you have indentations next to each nesting level, sometimes you don't.  If it looks like this in your development environment, you should fix it.  If it doesn't, then you need to check the preview when adding code to questions.  Usually copying the whole thing from your IDE, selecting it and clicking the {} icon will format the code correctly.

Consider this:

if(*it == "("){
    int i = 1;
    while(i != 0){
        it++;
        if(*it == ")"){i = i-1;}
        else if(*it == "("){i=i+1;}
        }
    }


At first glance, the final closing brace belongs to the while loop, not the if statement.  This is unnecessarily confusing.

Don't be afraid of using an extra line

Consider the following line or two:

for(string s: K){if( s!="(" and s!=")" ){int i = stoi(s); tmp.insert(i);}}


There's a lot going on there for a single line.  It's a lot easier to read spread across multiple lines:

for(string s: K) {
    if( s!="(" and s!=")" ) {
        int i = stoi(s); 
        tmp.insert(i);
    }
}