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:
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:
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