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

Skokovi

설명

In a land who knows where, in a world who knows when, lives a bee named Maya. Her adventure-filled
life is an endless source of ideas for tasks, so we chose one of them.
Maya’s friend, a grasshopper named Filip, is preparing for the Olympics in flower jumping. The flowers
in the meadow can be represented as a sequence of positive intergers \(a\) of length \(N\). The height of each
flower is given by the number \(a_{i}\).
Filip always jumps from left to right. Additionally, since this whole sport is new to him, he cannot jump
to a flower whose height differs too much from the one he is currently on. Specifically, from flower \(i\), he
can jump to flower \(j\) if and only if \(i < j\) and |\(a_{i} - a_{j}\)| ≤\(K\), where \(K\) is a positive integer given in the
input.
Help Maya plan Filip’s training by determining which flowers Filip can reach if he starts on the leftmost
flower. In other words, for each flower, determine if there is a sequence of jumps that leads to it, starting
from the first flower.

제약
입력 형식

The first line contains positive intergers \(N\) (\(1 \le N \le 2 \cdot 10^{5}\)) and \(K\) (\(1 \le K \le 10^{9}\)).
The second line contains a sequence of positive intergers \(a\), i.e., \(N\) numbers \(a_{i}\) (\(1 \le a_{i} \le 10^{9}\)), representing
the heights of the flowers.

출력 형식

In a single line, output \(N\) numbers, either 0 or 1, where each number indicates whether the corresponding
flower is reachable. The number 0 means that it is not possible to reach that flower, while 1 means the
flower is reachable. The first flower is always reachable as Filip starts from there.

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

1

20점

Flower heights are strictly increasing.

2

25점

\(N \le 1\,000\)

3

25점

No additional constraints.

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

Clarification of the first example:
Filip can jump directly from the first flower to the second. The third flower is unreachable as Filip cannot
jump to it from either the first or the second flower. To reach the fourth flower, Filip can also jump
directly from the first flower. For the last flower, Filip needs to jump first to the second flower and then
to the last flower.

문제 정보

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

출처 COCI 2024/2025 Contest 1

평가 및 의견

Skokovi

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

Log in to rate problems.

개별 의견

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

풀이 제출

Skokovi

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