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

Palindromi

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

의견: 0

설명

1 sekun\(da / 512\) M\(iB / 110\) points
You are given a sequence of \(n\) characters 0 or 1, indexed by numbers 1, 2, . . . , n. Initially every character
represents a string of length one. During a concatenation two words \(a\) and \(b\) are chosen, deleted, and
replaced by the string \(ab\) such that the characters of \(b\) are written after the characters of \(a\).
The \(n\) initial strings are concatenated to one final string using a sequence of \(n - 1\) concatenations. The \(i-th\)
of those concatenation is described by a pair of indexes (\(a@@RISE_MATH_BLOCK_0@@i-th\) character and the string containing \(b\)\(i-th\) character are to be concatenated. It is guaranteed that
characters with indexes \(a_{i}\) and \(b_{i}\) are not in the same string.
Palindromic value of some string \(w\) is defined as the total number of unique substrings of \(w\) which are
palindromes. We define palindromes as strings that are the same when read left to right and right to
left. A substring of a string is defined as a string obtained by erasing zero or more characters from the
beginning a\(nd/or\) ending of the string.
For every concatenation print the palindromic value of the resulting string.

제약

Subtask 1 (10 points): \(1 \le n \le 100\).

Subtask 2 (20 points): \(1 \le n \le 1000\).

Subtask 3 (30 points): \(a@@RISE_MATH_BLOCK_0@@i = i + 1\) for all \(i = 1\), 2, . . . , \(n - 1\).

Subtask 4 (50 points): No additional constraints. 1 sekun\(da / 512\) M\(iB / 110\) points

입력 형식

The first line contains an integer \(n\) (\(1 \le n \le 100\,000\)), number of characters.
In the second line there is a string of \(n\) characters 0 and 1 which represent the initial strings.
The \(i-th\) of following \(n - 1\) lines contains two integers \(a@@RISE_MATH_BLOCK_0@@i\) (\(1 \le a@@RISE_MATH_BLOCK_1@@i\)̸ = \(b\)\(i\)) representing the \(i-th\)
concatenation.

출력 형식

Print \(n - 1\) lines, the palindromic values of words obtained after each concatenation.

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

1

10점

\(1 \le n \le 100\).

2

20점

\(1 \le n \le 1000\).

3

30점

\(a@@RISE_MATH_BLOCK_0@@i = i + 1\) for all \(i = 1\), 2, . . . , \(n - 1\).

4

50점

No additional constraints. 1 sekun\(da / 512\) M\(iB / 110\) points

예제 1
입력
3
010
1 2
2 3
출력
2
3
예제 2
입력
5
00111
4 1
1 5
2 1
3 1
출력
2
3
4
5
예제 3
입력
8
10010000
7 5
4 2
3 6
1 3
6 8
5 3
1 2
출력
2
2
2
3
4
6
8
설명

Clarification of the third example:
Newly created strings after every concatenation are: 00, 10, 00, 100, 1000, 001000 and 00100010. Their
respective palindromic values are given in the example output. E. g. the palindromic value of 00100010
is 8 because the string contains 8 palindromic substring: 0, 00, 000, 10001, 0100010, 1, 010 i 00100.

문제 정보

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

출처 COCI 2021/2022 Contest 6

평가 및 의견

Palindromi

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

Log in to rate problems.

개별 의견

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

풀이 제출

Palindromi

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