Movie Booking Chaos
InterviewTime limit1sMemory limit1024 MB
Count the ways to place K club members in consecutive empty seats along one horizontal row, where '1' marks reserved seats.
- Level
Easy3 of 10
- Topics
- Array, Sliding window
- Solved
- No attempts yet
Problem
Doeun is going to a movie with her club members on the club culture day. The theater has seats arranged in a rectangle with rows and columns. Doeun values the bond among club members, so she wants to book seats that avoid the seats already reserved and let all club members sit side by side in a horizontal line. Help Doeun count the number of ways to book seats so that all club members can sit in a horizontal line. Arrangements that reserve the same seats, where only the positions of each person are swapped, count as one way.
Input
The first line contains (), the number of vertical lines of the theater, (), the number of horizontal lines, and (), the number of club members who will watch the movie.
From the second line onward, the next lines each contain a string of length . The -th character of shows the reservation status of seat in column . A '0' means the seat is empty and can be reserved, and a '1' means the seat is already reserved and cannot be booked.
Output
Print the number of ways to book the movie so that all club members can sit side by side in a horizontal line. If no booking satisfies the conditions, print .