There are two parties A and B going on.
Some people are going to party A, some are going to party B.
we
We are given instructions of the form
different 1 3, <-- meaning that person 1 and person 3 are attending different parties
same 3 4,
different 4 5,
different 1 3
, meaning that person 1 and person 3 are attending different partiessame 3 4
,different 4 5
,
and then given a command tell 1 4 wetell 1 4
we have to answer if they are attending the same party
oror a different.
Like from above we can conclude that 1 and 4 must be attending different party
asas 1 and 3 are attending different and 3 and 4 attend the same.
My thoughts :
Make Make a hash table for A and B
given x and y determine which one belongs to which hashtable
if any not present put it in the appropriate hashtable.
Not sure if this is an efficient algorithm for this.
I
I was wondering if we could build a graph from the given info and then we
can answer any amount of questions like that.