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

Dirigent

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

의견: 0

설명

Winter school of informatics ends with a traditional dance. There are \(n\) students
who participate. Each of them has a unique label between 1 and \(n\).
First, conductor Krešo orders the students to form a circle such that each student
holds hands with two other students.
Alenka is wondering if it is possible to break the circle by making exactly one pair
of neighbouring students stop holding hands and that the newly formed sequence
of students is sorted by their labels. For example, if their order is 3 4 1 2, than
the circle can be broken between students with labels 4 and 1, but if their order is 2 1 4 3, than there is
no way to break the circle in such way.
During the night Krešo is going to give \(q\) instructions. In each of them, he is going to order two students
to swap places. After each swap you need to help Alenka answer her question.

제약

Subtask 1 (15 points): n, \(q \le 500\)

Subtask 2 (20 points): n, \(q \le 5\,000\)

Subtask 3 (35 points): No additional constraints.

입력 형식

The first line contains two integers \(n\) and \(q\) (\(1 \le n\), \(q \le 300\,000\)), the number of students and the number
of swaps.
The second line contains \(n\) integers \(a@@RISE_MATH_BLOCK_0@@i \le n\)), describing the initial placement of students in the
circle.
In each of the next \(q\) lines there are two integers \(x@@RISE_MATH_BLOCK_1@@i\) (\(1 \le x@@RISE_MATH_BLOCK_2@@i\)̸ = \(y\)\(i\)), that describe Krešo’s \(i-th\)
instruction in which students with labels \(x_{i}\) and \(y_{i}\) swap places.

출력 형식

In the \(i-th\) of the \(q\) lines outs put the answer to Alenka’s question after \(i\) swaps have been carried out. If
the answer is affirmative output DA, otherwise NE.

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

1

15점

n, \(q \le 500\)

2

20점

n, \(q \le 5\,000\)

3

35점

No additional constraints.

예제 1
입력
5 2
2 3 4 5 1
1 3
3 1
출력
NE
DA
예제 2
입력
4 2
2 3 1 4
4 2
3 4
출력
NE
DA
예제 3
입력
6 5
2 1 5 6 3 4
3 1
3 4
3 2
4 5
5 4
출력
NE
NE
DA
NE
DA
설명

Clarification of the second example:
Students in the beginning, after the first and after the second swap.

문제 정보

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

출처 COCI 2022/2023 Contest 3

평가 및 의견

Dirigent

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

Log in to rate problems.

개별 의견

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

풀이 제출

Dirigent

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