欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1820B.JoJo's Incredible Adventures
JoJo's Incredible Adventures
Did you think there was going to be a JoJo legend here? But no, that was me, Dio!
Given a binary string of length , consisting of characters 0 and 1. Let's build a square table of size , consisting of 0 and 1 characters as follows.
In the first row of the table write the original string . In the second row of the table write cyclic shift of the string by one to the right. In the third row of the table, write the cyclic shift of line by two to the right. And so on. Thus, the row with number will contain a cyclic shift of string by to the right. The rows are numbered from to top-to-bottom.
In the resulting table we need to find the rectangle consisting only of ones that has the largest area.
We call a rectangle the set of all cells in the table, such that and for some integers and .
Recall that the cyclic shift of string by to the right is the string . For example, the cyclic shift of the string "01011" by to the right is the string itself "01011", its cyclic shift by to the right is the string "01101".
Input
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of test cases follows.
The first and the only line of each test case contains a single binary string (), consisting of characters 0 and 1.
It is guaranteed that the sum of string lengths over all test cases does not exceed .
Output
For each test case, output a single integer — the maximum area of a rectangle consisting only of ones. If there is no such rectangle, output .
Note
In the first test case, there is a table consisting of a single character 0, so there are no rectangles consisting of ones, and the answer is .
In the second test case, there is a table , consisting of a single character 1, so the answer is .
In the third test case, there is a table:
| 1 | 0 | 1 |
|---|---|---|
| 1 | 1 | 0 |
| 0 | 1 |
In the fourth test case, there is a table:
| 0 | 1 | 0 | |||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | ||||
| 1 | 0 | ||||
| 1 | 0 | ||||
| 1 | 0 | ||||
In the fifth test case, there is a table:
| 1 | 0 | 1 | 0 | 1 | 0 |
|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 | 1 |
Rectangles with maximum area are shown in bold.
Samples
5
0
1
101
011110
101010
0
1
2
6
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |