Help needed to solve this problem!!

Revision en2, by aya1909, 2020-11-26 05:55:16

The ememy of your ememy is friend.Given Q queries of form:

1 person1 person2

2 0 person

person is signified using id

your id is 0

for query of type 2 print following:

-1 if person is your enemy

1 if person is your friend

0 if person is not related to you

A person is your friend if he is:

enemy of your enemy

enemy of your's friend enemy and so on

constraints : 0<id<10^5 0<Q<10^5

example:

1 1 2

1 0 1

1 3 4

2 0 1

2 0 2

2 0 4

output:

-1

1

0

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English aya1909 2020-11-26 05:55:16 34
en1 English aya1909 2020-11-26 05:53:34 514 Initial revision (published)