aya1909's blog

By aya1909, history, 3 years ago, In English

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

  • Vote: I like it
  • -14
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by aya1909 (previous revision, new revision, compare).

»
3 years ago, # |
  Vote: I like it +16 Vote: I do not like it

Link to problem? Nowadays, more people are asking for help on an ongoing contest.