GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Sunday, 8 May 2022

Tokitsukaze and Meeting Codeforces Solution | Codeforces Problem Solution 2022

D. Tokitsukaze and Meeting
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Tokitsukaze is arranging a meeting. There are n rows and m columns of seats in the meeting hall.

There are exactly nm students attending the meeting, including several naughty students and several serious students. The students are numerated from 1 to nm. The students will enter the meeting hall in order. When the i-th student enters the meeting hall, he will sit in the 1-st column of the 1-st row, and the students who are already seated will move back one seat. Specifically, the student sitting in the j-th (1jm1) column of the i-th row will move to the (j+1)-th column of the i-th row, and the student sitting in m-th column of the i-th row will move to the 1-st column of the (i+1)-th row.

Solution Click Below:-  CLICK HERE

For example, there is a meeting hall with 2 rows and 2 columns of seats shown as below:

There will be 4 students entering the meeting hall in order, represented as a binary string "1100", of which '0' represents naughty students and '1

[Solution] Tokitsukaze and Good 01-String

Tokitsukaze and Two Colorful Tapes Codeforces Solution

Tokitsukaze and Permutations Codeforces Solution

represents serious students. The changes of seats in the meeting hall are as follows:

Denote a row or a column good if and only if there is at least one serious student in this row or column. Please predict the number of good rows and columns just after the i-th student enters the meeting hall, for all i.

Input

The first contains a single positive integer t (1t10000) — the number of test cases.

For each test case, the first line contains two integers nm (1n,m1061nm106), denoting there are n rows and m columns of seats in the meeting hall.

The second line contains a binary string s of length nm, consisting only of zeros and ones. If si equal to '0' represents the i-th student is a naughty student, and si equal to '1' represents the i-th student is a serious student.

It is guaranteed that the sum of nm over all test cases does not exceed 106.

Output

For each test case, print a single line with nm integers — the number of good rows and columns just after the i-th student enters the meeting hall.

Join Now for Solution:- 

No comments:

Post a Comment