Special circles

1

6 votes
Maximum Bipartite Matching, Algorithms, Graphs
Problem

In a binary list, the small positions are called bino positions. Each bino position has a favorite number. A favorite number of the \(i^{th}\) bino with \(fn_i\). The \(i^{th}\) bino is better than the \(j^{th}\) bino if and only if the number of 1 in the binary representation of \((fn_i | fn_j) ^ {fn_i}\) is odd. 

A special circle contains at least two positions where the left bino is better than the other. The next bino is in the clockwise direction. 

Your task is to divide the binos into several groups so that the members of each group can form a special circle.rm a lovely circle.

Input format

  • First line: An integer \(n\) denoting the number of binos (\(1 \le n \le 5000\))
  • Next line: \(n\) space-separated integers where the \(i^{th}\) integer is \(fn_i\) denotes the favorite number of the \(i^{th}\) bino (\(0 \le fn_i < 2^{30}\))

Output format

If you cannot divide the binos, print 'NO'. Otherwise, print 'YES'.

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

In the first sample, both bino think they are better than the other. Therefore They can form the lovely circle together.


In the second sample, there is no way for Jenny to do what she wants.

Editor Image

?