포럼
문제 COCI00455

Doktor

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

And the Mrs, Ms, says:
“I’ve been riding horses for fifteen years, and \(it\) \(is\) impossible \(to\) shoe \(a\) horse upside down!”
(...)
“Yes, that’s upside down” - whispers Domagoj, looking at Mate’s hand while playing, for the
purposes of this task, a heavily modified version of the card game Hanabi. For the sake of
simplicity, Mate is holding \(N\) cards in his hands, numbered from 1, 2, ..., \(N\) in a certain order.
(Each number from 1 to \(N\) appears exactly once.) As when playing the real game, he cannot
voluntarily change the card order.
Just so the task is at least somewhat related to the story, Domagoj will point for Mate to a
contiguous subarray of cards. (He can point to a single card too, but he will point to at least
one card.) Mate will then “rotate” that contiguous subarray and put it back.
(The rotating can be thought of as taking all the cards in the given subarray and rotating all
of them for 180 degrees. This means that the first and last card swap places, as well as the
second and the second to last card, and so on.)
Like all of us, Domagoj is very fond of fixed points. In other words, cards whose numbers
match their position in hand, counting from Domagoj’s left side. Therefore, he’d like the
number of fixed points to be as great as possible after rotating the given subarray.
Help Domagoj find out which contiguous subarray he needs to point out so that the number
of fixed points in Mate’s hand after rotating that subarray is maximal.

제약

In test cases worth 30% of total points, it will hold \(N \le 500\).
In test cases worth an additional 30% of total points, it will hold \(N \le 5000\).

입력 형식

The first line of input contains the positive integer \(N\) (\(1 \le N \le 500\,000\)), the number of cards
in Mate’s hand.
The following line contains the numbers on the cards in Mate’s hand in the order that
Domagoj sees them.

출력 형식

You must output a single line containing \(A\) and \(B\), the numbers on the cards that are the
beginning and the end of the required contiguous subarray, in that order. If there are multiple
options, output any of them.

예제 1
입력
4
3 2 1 4
출력
3 1
예제 2
입력
2
1 2
출력
1 1
예제 3
입력
7
3 6 5 7 4 1 2
출력
3 2
문제 정보

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

출처 COCI 2017/2018 Contest 2

평가 및 의견

Doktor

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

Log in to rate problems.

개별 의견

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

풀이 제출

Doktor

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