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

Volontiranje

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

의견: 0

설명

It is not so well known that in his free time, Mr.
Malnar cotributes to the
community by volunteering. That’s right! He is quite active at the volunteering
center for informatics problems.
Recently, he got a call from the center and, as it turns out, there is a shortage of
increasing sequences. Mr. Malnar, who is always willing to help, responded readily.
Namely, he keeps an array of \(n\) integers for this very purpose. All of the integers
from 1 to \(n\) appear exactly once in his array.
Mr. Malnar will select a few increasing subsequences from his array, which he will
donate to the center, and he will keep the rest of the numbers for some other time. It must be noted that
each number from the array can be used for at most one subsequence, that is, the selected subsequences
have distinct indices.
A subsequence is defined as any sequence obtained from the array by deleting some (maybe none) of the
elements, while preserving the order of the remaining elements. A subsequence is said to be increasing if
every number in the subsequence (except for the first one) is larger than the previous one.
Because Mr. Malnar is very generous, he wants all of the sequences he donates to be longest increasing
subsequences. In other words, if \(l\) is the length of the longest increasing subsequence of the staring array,
Mr. Malnar will select a couple of disjoint increasing subsequences, each of length \(l\).
Mr. Malnar wants to donate as many subsequences as possible. For a given array of Mr. Malnar, print
the maximum number of subsequences which comprise his selection and provide an example of such a
selection.

제약

Subtask 1 (10 points): \(1 \le n \le 15\)

Subtask 2 (40 points): \(1 \le n \le 1000\)

Subtask 4 (60 points): \(1 \le n \le 1\,000\,000\)

입력 형식

The first line contains the integer \(n - th\)e size of the array.
The second line contains \(n\) numbers \(p@@RISE_MATH_BLOCK_0@@i \le n\)) which represent the elements of the array. Each
positive integer \(j\) between 1 and \(n\) appears exactly once in the array.

출력 형식

In the first line, print the largest possible number of subsequences in Mr. Malnar’s selection, as well as
the length of the longest increasing subsequence.
In each of the following lines print one of the subsequences from such a selection. A subsequence is defined
by a list of position, i.e. indices of the array, which should be sorted in increasing order.
The printed subsequences should be increasing, disjoint and have the same leng\(th - th\)e length of the
longest increasing subsequence.
The relative order of the subsequences does not matter. Also, if there is more than one solution, you can
print any.

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

Clarification of the third example:
The length of the longest increasing subsequence is 3. The subsequence determined by indices 1, 3, and
5 (or, values 2, 6 and 7) is increasing. The subsequence determined by indices 2, 6 and 7 (or, values
1, 3 and 4) is also incrasing. The two subsequences have no elements in common and they also have
maximum lenght, which is why this is a valid selection. It is not possible to choose more than two of such
subsequences.

문제 정보

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

출처 COCI 2021/2022 Contest 1

평가 및 의견

Volontiranje

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

Log in to rate problems.

개별 의견

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

풀이 제출

Volontiranje

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