각 정점에 토큰 값이 있는 트리에서 라운드는 비트 AND 통행료를 내며 이동하고, 시작과 끝 쌍이 겹치지 않게 여러 라운드를 돌아 얻는 토큰 합의 최댓값을 구한다.
어려움8트리동적 계획법비트 연산그리디아직 제출이 없습니다시간 제한3초메모리 제한512 MBBinary Casino is a very special skyscraper building consisting of N floors connected by a tricky network of high speed escalators.
The floor connections are designed in a way that if there is an escalator going from floor A to floor B, then there is another escalator going from floor B to floor A as well. Also, for any two floors A and B, there is exactly one way to go from floor A to floor B.
Your manager decided to organize a promotion game to attract more customers. The game has the following rules:
Your manager is curious about the maximum number of tokens a customer can earn in the game.
The first line of input contains an integer N (1 ≤ N ≤ 3 · 105) describing the number of floors in the casino skyscraper. The second line contains N integers Vi (0 ≤ Vi < 220). The i-th integer Vi describes the number of tokens that a customer earns on the i-th floor. After that, N −1 lines follow. Each line contains two integers A and B (0 ≤ A, B < N) which describe an escalator connection between floors A and B.
Output a single number – the maximum number of tokens a customer can earn.