Tokitsukaze and Meeting Codeforces Solution | Codeforces Problem Solution 2022
Tokitsukaze is arranging a meeting. There are rows and columns of seats in the meeting hall.
There are exactly students attending the meeting, including several naughty students and several serious students. The students are numerated from to . The students will enter the meeting hall in order. When the -th student enters the meeting hall, he will sit in the -st column of the -st row, and the students who are already seated will move back one seat. Specifically, the student sitting in the -th () column of the -th row will move to the -th column of the -th row, and the student sitting in -th column of the -th row will move to the -st column of the -th row.
For example, there is a meeting hall with rows and columns of seats shown as below:
![](https://espresso.codeforces.com/71fbef301db6ce11000b1d81b932ef15edcc4d8c.png)
There will be 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:
![](https://espresso.codeforces.com/6adf53c6760706e7188b39c11a0473a15cb0ae60.png)
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 -th student enters the meeting hall, for all .
The first contains a single positive integer () — the number of test cases.
For each test case, the first line contains two integers , (; ), denoting there are rows and columns of seats in the meeting hall.
The second line contains a binary string of length , consisting only of zeros and ones. If equal to '0' represents the -th student is a naughty student, and equal to '1' represents the -th student is a serious student.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print a single line with integers — the number of good rows and columns just after the -th student enters the meeting hall.
Join Now for Solution:-
No comments:
Post a Comment