RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00544

Klasika

Unrated 레이팅 미적용
난이도
5s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

In the beginning there was a node denoted as 1 and it represented the root of a tree. Your task is to
support \(Q\) queries of the form:
• Add x y – Adds a new node to the tree as a child of node \(x\). The newly added node and node \(x\) are
connected with an edge of weight \(y\). The newly added node is denoted by a number equal to the
number of nodes that the tree consists of after its addition.
• Query a b – Finds the longest path in a tree which starts in node \(a\) and ends in some node from
the subtree of node \(b\) (which itself is considered to be in its own subtree). The length of the path is
defined as exclusive or (xor) of weights of all edges that the path consists of.

제약

Subtask
Score
Constraints
1
11
\(Q \le 200\)
2
22
\(Q \le 2\,000\)
3
33
In all queries of type Query it holds \(b = 1\)
4
44
No additional constraints.

입력 형식

The first line contains an integer \(Q\) (\(1 \le Q \le 200\,000\)) from the task description.
The \(i-th\) of the next \(Q\) lines contains the \(i-th\) query whose format corresponds to one of the queries from
the task description. Values \(x\), \(a\) and \(b\) will refer to an existing node at that moment and value \(y\) will not
be greater than \(2^{30}\).

출력 형식

You should output an answer to each query of type Query. Each answer should be printed in a separate
line in the order in which corresponding queries appear in the input.

예제 1
입력
4
Add 1 5
Query 1 1
Add 1 7
Query 1 1
출력
5
7
예제 2
입력
6
Add 1 5
Add 2 7
Add 1 4
Add 4 3
Query 1 1
Query 2 4
출력
7
2
예제 3
입력
10
Add 1 4
Add 1 9
Add 1 10
Add 2 2
Add 3 3
Add 4 4
Query 4 2
Query 1 3
Add 6 7
Query 1 3
출력
14
10
13
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2019/2020 Contest 4

평가 및 의견

Klasika

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Klasika

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