RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0369 파일 입출력

Cow Land

Platinum I 플래티넘 I
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Cow Land is a special amusement park for cows, where they roam around, eat
delicious grass, and visit different cow attractions (the roller cowster is
particularly popular).

There are a total of \(N\) different attractions (\(2 \leq N \leq 10^5\)). Certain
pairs of attractions are connected by pathways, \(N-1\) in total, in such a way
that there is a unique route consisting of various pathways between any two
attractions. Each attraction \(i\) has an integer enjoyment value \(e_i\), which can
change over the course of a day, since some attractions are more appealing in
the morning and others later in the afternoon.

A cow that travels from attraction \(i\) to attraction \(j\) gets to experience all
the attractions on the route from \(i\) to \(j\). Curiously, the total enjoyment
value of this entire route is given by the bitwise XOR of all the enjoyment
values along the route, including those of attractions \(i\) and \(j\).

Please help the cows determine the enjoyment values of the routes they plan to
use during their next trip to Cow Land.

Problem credits: Charles Bailey

제약

Problem credits: Charles Bailey

입력 형식

The first line of input contains \(N\) and a number of queries \(Q\)
(\(1 \leq Q \leq 10^5\)). The next line contains \(e_1 \ldots e_N\)
(\(0 \leq e_i \leq 10^9\)). The next \(N-1\) lines each describe a pathway in terms
of two integer attraction IDs \(a\) and \(b\) (both in the range \(1 \ldots N\)).
Finally, the last \(Q\) lines each describe either an update to one of the \(e_i\)
values or a query for the enjoyment of a route. A line of the form "1 \(i\) \(v\)"
indicates that \(e_i\) should be updated to value \(v\), and a line of the form "2
\(i\) \(j\)" is a query for the enjoyment of the route connecting attractions \(i\)
and \(j\).

In test data worth at most 50% of points, there will be no changes to the values
of the attractions.

출력 형식

For each query of the form "2 \(i\) \(j\)", print on a single line the enjoyment of
the route from \(i\) to \(j\).

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 cowland.in
출력을 쓸 파일 cowland.out
예제 1
입력
5 5
1 2 4 8 16
1 2
1 3
3 4
3 5
2 1 5
1 1 16
2 3 5
2 1 5
2 1 3
출력
21
20
4
20
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2018-2019 > February > Gold

태그

평가 및 의견

Cow Land

개요
출제자 난이도 Platinum I 플래티넘 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Cow Land

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8