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

Lampice

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

의견: 0

설명

Little Vera really likes Advent and Christmas time. Most of all, she likes colorful
Christmas lights and enjoys decorating her balcony with shining colors. To decorate
her balcony, she bought a sequence of \(n\) lights connected in a row, each shining in one
of a thousand different colors.
Apart from lights, Vera also really likes repeating patterns, so she would like to have her
balcony decorated so that a certain pattern of colors repeats \(k\) times in a row. However,
the lamps she bought might not satisfy her obsession of repetition and patterns, so she decided to cut off
zero or more lamps from the beginning and from the end of the sequence to obtain a sequence in which a
pattern of colors repeats \(k\) times in a row.
Help her determine whether she can obtain such a sequence of lights by making the mentioned cuts, and
if so, print the pattern that will be repeated.

제약

Subtask 1 (10 points): The sequence contains a pattern of a single light repeated \(k\) times in a row.

Subtask 2 (15 points): \(k = 2\)

Subtask 3 (25 points): No additional constraints.

입력 형식

The first line contains positive integers \(n\) and \(k\) (\(1 \le k \le n \le 50\)) described above.
The second line contains a sequence of positive integers \(a\)1, a2, ..., a\(n\) (\(1 \le a\)\(i \le 1000\)) which denotes the
colors of the lamps that Vera bought, in the order they appear in her sequence.

출력 형식

If Vera can’t cut out a sequence of lights that she wants, pri\(nt -1\).
If Vera can cut out a sequence of lights that she wants, in the first line print the length of the repeating
pattern, and in the second line print the sequence of colors that makes up the pattern. If there is more
than one solution, you can output any one of them.

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

1

10점

The sequence contains a pattern of a single light repeated \(k\) times in a row.

2

15점

\(k = 2\)

3

25점

No additional constraints.

예제 1
입력
8 6
10 1 1 1 1 1 1 5
출력
1
1
예제 2
입력
3 2
1 2 1
출력
-1
예제 3
입력
10 2
1 5 1 5 2 5 6 2 5 6
출력
2
1 5
설명

Clarification of the third example: If Vera cuts off six lights from the end and zero from the beginning,
she obtains the sequence of lights 1 5 1 5, in which the pattern 1 5 repeats twice in a row. If, on the
other hand, she cuts off four lights from the beginning and zero from the end, she obtains the sequence of
lights 2 5 6 2 5 6, in which the pattern 2 5 6 repeats twice, so this is also a valid solution.

문제 정보

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

출처 COCI 2021/2022 Contest 3

평가 및 의견

Lampice

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

Log in to rate problems.

개별 의견

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

풀이 제출

Lampice

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