You are on page 1of 2

4/2/24, 9:01 AM Problem - 1820B - Codeforces

|
riteshnub | Logout
You have +385! Wow!

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP

PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST

00:00:07

Codeforces Round 866 (Div. 2)


Finished
B. JoJo's Incredible Adventures
time limit per test: 1 second Practice
memory limit per test: 256 megabytes
input: standard input
output: standard output
→ Virtual participation 
Did you think there was going to be a JoJo legend here? But no, that was me, Dio!
Virtual contest is a way to take part in past
contest, as close as possible to participation
Given a binary string s of length n, consisting of characters 0 and 1. Let's build a square on time. It is supported only ICPC mode for
table of size n × n, consisting of 0 and 1 characters as follows. virtual contests. If you've seen these
problems, a virtual contest is not for you -
solve these problems in the archive. If you
In the first row of the table write the original string s . In the second row of the table write cyclic just want to solve some problem from a
shift of the string s by one to the right. In the third row of the table, write the cyclic shift of line contest, a virtual contest is not for you -
solve this problem in the archive. Never use
s by two to the right. And so on. Thus, the row with number k will contain a cyclic shift of string someone else's code, read the tutorials or
s by k to the right. The rows are numbered from 0 to n − 1 top-to-bottom.
communicate with other person during a
virtual contest.

In the resulting table we need to find the rectangle consisting only of ones that has the largest Start virtual contest
area.

We call a rectangle the set of all cells (i, j) in the table, such that x 1 ≤ i ≤ x 2 and
y1 ≤ j ≤ y2 for some integers 0 ≤ x 1 ≤ x 2 < n and 0 ≤ y1 ≤ y2 < n .
→ Clone Contest to Mashup 
You can clone this contest to a mashup.
Recall that the cyclic shift of string s by k to the right is the string
sn−k+1 … sn s1 s2 … sn−k . For example, the cyclic shift of the string "01011" by 0 to the Clone Contest
right is the string itself "01011", its cyclic shift by 3 to the right is the string "01101".

Input → Submit?
Each test consists of multiple test cases. The first line contains a single integer t (
4
1 ≤ t ≤ 2 ⋅ 10 ) — the number of test cases. The description of test cases follows. Language: GNU G++17 7.3.0

The first and the only line of each test case contains a single binary string s ( Choose
Choose File No file chosen
1 ≤ |s| ≤ 2 ⋅ 10
5
), consisting of characters 0 and 1. file:

5
Submit
It is guaranteed that the sum of string lengths |s| over all test cases does not exceed 2 ⋅ 10 .

Output
For each test case, output a single integer — the maximum area of a rectangle consisting only → Problem tags
of ones. If there is no such rectangle, output 0.
math strings two pointers *1100
Example No tag edit access

input Copy

5 → Contest materials
0
1 Announcement (en)
101
011110 Tutorial (en)
101010

output Copy

0
1
2
6
1

Note
In the first test case, there is a table 1 × 1 consisting of a single character 0, so there are no
rectangles consisting of ones, and the answer is 0.

https://codeforces.com/problemset/problem/1820/B 1/2
4/2/24, 9:01 AM Problem - 1820B - Codeforces
In the second test case, there is a table 1 × 1, consisting of a single character 1, so the
answer is 1.

In the third test case, there is a table:

1 0 1

1 1 0

0 1 1

In the fourth test case, there is a table:

0 1 1 1 1 0

0 0 1 1 1 1

1 0 0 1 1 1

1 1 0 0 1 1

1 1 1 0 0 1

1 1 1 1 0 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.

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Apr/02/2024 09:00:41UTC+5.5 (f1).
Desktop version, switch to mobile version.
Privacy Policy

Supported by

https://codeforces.com/problemset/problem/1820/B 2/2

You might also like