페이지를 불러오는 중…
해결한 사람
1
명
정답률
50.00
%
시간 제한
1000
ms
메모리 제한
2048
MB
Carlos spends his summer holiday studying duplicated binary strings. A duplicated binary string is a non-empty string such that:
0 and 1 (that is, is a binary string).For example, 0000 and 011011 are duplicated binary strings, but 01, 0110, and 000 are not.
Define the strength of a binary string as the number of distinct contiguous duplicated substrings present in . Two substrings are considered different if they differ in at least one character.
This problem consists of two parts, with each subtask associated with either Part I or Part II. You may solve the subtasks in any order; in particular, you are not required to complete all of Part I before attempting Part II.
Carlos sends you a binary string , and your task is to calculate its strength.
You should implement the following procedure.
int count_duplicated(std::string S)
The procedure should return an integer , the number of distinct contiguous duplicated substrings present in .
0 or 1 for each such that .| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 6 | |
| 2 | 9 | No additional constraints. |
Example 1
Consider the following call.
count_duplicated("0101")
There is only one duplicated binary substring in , which is 0101. Therefore the procedure should return .
Example 2
Consider the following call.
count_duplicated("0000")
There are two duplicated binary substrings in : 00 and 0000. Hence, the procedure should return .
Note that although the substring 00 appears three times in , it is counted only once in the final answer.
Carlos wonders what the minimum and maximum strength of a binary string can be.
Your task is to construct binary strings of length that contain as few or as many duplicated substrings as possible. You will receive a score based on the number of duplicated substrings.
| 번호 | 배점 | 제한 |
|---|---|---|
| 3 | 25 | Minimize the strength of . |
| 4 | 60 | Maximize the strength of . |
For each subtask, you should return a binary string in your program to a grader procedure call.
To construct the required binary strings in your solution program, you should implement the following procedures.
std::string find_weakest()
The procedure should return a binary string of length with minimum strength.
std::string find_strongest()
The procedure is called in Subtask 4 exactly once.
The procedure should return a binary string of length with maximum strength.
If your output does not conform to the constraints described in the implementation details, the score of your solution for that subtask will be .
Let denote the strength of the string in your output for a given subtask.
In Subtask 3, your score is calculated according to the following table:
| Condition | Points |
|---|---|
In Subtask 4, your score is calculated according to the following table:
| Condition | Points |
|---|---|
Parts I and II use the same sample grader program, with the distinction between the two parts determined by the first line of the input.
Input format for Part I:
1
S
Output format for Part I:
K
Input format for Part II:
2
T
Here, T is either the string weakest or the string strongest.
Output format for Part II:
S
Note that the output of the sample grader adheres to the required format for the output files in Part II.
for Part I:
1
S
for Part I:
K
Input format for Part II:
2
T
Here, T is either the string weakest or the string strongest.
Output format for Part II:
S
Note that the output of the sample grader adheres to the required format for the output files in Part II.
1
0101
1
1
0000
2
International Olympiad in Informatics (IOI) 2025, official task package; Korean translation by Reporch.
Reporch에서 한국어 번역, 수식 표기, 이미지 호스팅 및 형식을 수정했습니다.
로그인 상태를 확인하는 중입니다.