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

Specijacija

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

의견: 0

설명

4 secon\(ds / 1\) G\(iB / 110\) points
You are given a positive integer \(n\) and a sequence \(a\)1, a2, . . . , a\(n\) of positive integers, such that {i}{i}}^{1)
2
<
\(a_{i}\){i}{i}
2
.
The sequence parameterizes a tree with {(}{+1)(}}^{+2)
2
vertices, consisting of \(n + 1\) levels with 1, 2, . . . , \(n + 1\)
vertices, in the following way:
1
2
4
7
5
8
3
6
9
10
The tree parameterized by \(a\) = (1, 2, 6).
The \(i-th\) level contains vertices {i}{i}}^{1)
2
+ 1, . . . , {i}{i}
2
. The vertex \(a_{i}\) has two children, and the rest of the
vertices on the level have one child each.
We want to answer \(q\) queries of the form “what is the largest common ancestor of \(x\) and \(y\)”, i.e. the vertex
with the largest label which is an ancestor of both \(x\) and \(y\).

제약

Subtask 1 (10 points): \(q = 1\), \(t = 0\)

Subtask 2 (10 points): \(n \le 1000\), \(t = 0\)

Subtask 3 (30 points): \(t = 0\)

Subtask 4 (60 points): \(t = 1\)

입력 형식

The first line contains integers \(n\), \(q\) and \(t\) (\(1 \le n\), \(q \le 200\,000\), \(t\) ∈{0, 1}), the number of parameters, the
number of queries, and a value which will be used to determine the labels of vertices in the queries.
The second line contains a sequence of \(n\) integers \(a@@RISE_MATH_BLOCK_0@@i\) and e\(y@@RISE_MATH_BLOCK_1@@x@@RISE_MATH_BLOCK_2@@i\){(}{+1)(}}^{+2)
2
) which will be
used to determine the labels of vertices in the queries.
Let \(z@@RISE_MATH_BLOCK_3@@0 = 0\). The labels in the \(i-th\) query \(x@@RISE_MATH_BLOCK_4@@i\) are:
\(x_{i}\) =

(e\(x_{i} - 1 + t \cdot z_{i}\){−}) mod {(}{+1)(}}^{+2)
2

+ 1,
\(y_{i}\) =

(e\(y_{i} - 1 + t \cdot z_{i}\){−}) mod {(}{+1)(}}^{+2)
2

+ 1,
where mod is the remainder of integer divison.
Remark: Note that if \(t = 0\), it holds \(x@@RISE_MATH_BLOCK_5@@x@@RISE_MATH_BLOCK_6@@i = e@@RISE_MATH_BLOCK_7@@i\), so all queries are known from input. If \(t = 1\), the
queries are not known in advance, but are determined using answers to previous queries.

출력 형식

Output \(q\) lines. In the \(i-th\) line, output the largest common ancestor of \(x@@RISE_MATH_BLOCK_0@@i\).
4 secon\(ds / 1\) G\(iB / 110\) points

서브태스크
서브태스크점수설명

1

10점

\(q = 1\), \(t = 0\)

2

10점

\(n \le 1000\), \(t = 0\)

3

30점

\(t = 0\)

4

60점

\(t = 1\)

예제 1
입력
3 5 0
1 2 6
7 10
8 5
6 2
9 10
2 3
출력
1
5
1
6
1
예제 2
입력
3 5 1
1 2 6
7 10
8 5
6 2
9 10
2 3
출력
1
6
2
1
1
설명

Clarification of the examples:
The tree from both examples is shown on the figure in the statement.
Labels of verticies in queries in the second example are:
x1 = 7, y1 = 10,
x2 = 9, y2 = 6,
x3 = 2, y3 = 8,
x4 = 1, y4 = 2,
x5 = 3, y5 = 4.

문제 정보

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

출처 COCI 2020/2021 Contest 3

평가 및 의견

Specijacija

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

Log in to rate problems.

개별 의견

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

풀이 제출

Specijacija

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