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

Gift Boxes

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
설명

This year's EGOI is organized in Bonn. The organizers want to distribute at most one gift box to every team in the contest, with each team represented by a number from \(0\) to \(T-1\). The contestants are standing in a single row. However they are mixed up such that people from the same team might not be standing next to each other. Note that there will be at least one team with more than one person in the row. There are \(N\) people in the row. Person \(i\) is part of the team \(a_i\). The problem is: each team should only receive a maximum of one gift box. In order to ensure the process runs smoothly - and willing to leave some teams with no gift as a consequence - the organisers wish to pause the gifting process exactly once, skipping a few contestants before resuming the gift box handouts. In other words, they will skip one consecutive segment \([\ell, r]\) of the contestants.

It is not necessary that every team receives a gift. Nevertheless, the organizers want to maximize the number of teams that will receive their gifts while ensuring that no team ends up with two or more gifts, equivalent to minimizing the number of contestants that are skipped under this condition. Please help the organizers to decide when it is best to pause and when to continue distributing gifts such that as few contestants as possible are skipped.

(An illustrative figure from the official statement is omitted here.)

제약
  • \(1 \leq T < N \leq 500\,000\).
  • \(0 \leq a_i \leq T-1\).

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group, you need to solve all test cases in the test group.

Group | Score | Limits 1 | 8 | \(N = T + 1\), i.e. only one team will appear twice 2 | 11 | \(N = 2 \cdot T\) and every team will appear exactly once in the first half and exactly once in the second half of the line 3 | 14 | \(1 \leq T < N \leq 500\) 4 | 21 | \(N = 2 \cdot T\) and every team will appear twice 5 | 22 | \(1 \leq T < N \leq 5\,000\) 6 | 24 | No additional constraints

입력 형식

The first line of input contains two integers, \(T\) and \(N\) – the number of teams and the number of contestants in the row.

The second line contains \(N\) integers, \(a_i\), where the \(i\)th integer describes which team the person at position \(i\) in the row belongs to. It is guaranteed that every integer between \(0\) and \(T-1\) appears at least once.

출력 형식

Output two integers, \(\ell\) and \(r\), where \(\ell\) is the index of the first person that is skipped and \(r\) is the index of the last skipped person. Note that \(\ell\) and \(r\) are indexed from \(0\) to \(N-1\). If there is more than one solution, print any one of them.

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

Subtask 1

8점

None

Subtask 2

11점

None

Subtask 3

14점

None

Subtask 4

21점

None

Subtask 5

22점

None

Subtask 6

24점

None

예제 1
입력
4 5
1 3 0 2 3
출력
1 1
예제 2
입력
3 6
1 0 2 2 1 0
출력
0 2
예제 3
입력
4 8
0 2 0 1 2 1 3 3
출력
2 6
예제 4
입력
3 6
1 1 2 0 1 0
출력
0 3
예제 5
입력
4 6
0 1 2 0 3 2
출력
2 3
예제 6
입력
5 13
3 3 3 1 2 0 3 3 2 1 4 1 0
출력
1 9
문제 정보

rip 작성

출처 EGOI 2025

평가 및 의견

Gift Boxes

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

Log in to rate problems.

개별 의견

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

풀이 제출

Gift Boxes

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