Special School Escape
InterviewTime limit1sMemory limit1024 MB
Given N teacher patrol strings over M periods, find the earliest period when no teacher patrols, or report ESCAPE FAILED if none exists.
- Level
Easy2 of 10
- Topics
- Implementation, String
- Solved
- No attempts yet
Problem
Students at NLCS Jeju are tired of classes and want to escape from school. Escaping during class hours is difficult.
Class hours at NLCS Jeju run from period to period . There are teachers at NLCS Jeju, and each teacher patrols during class hours between period and period according to a fixed schedule. To avoid being caught, students must escape when no teacher is patrolling. If a patrolling teacher is present at the moment students try to escape, they are caught without fail.
Given the patrol schedule of each teacher, determine whether the students can escape from school, and if they can, find the earliest time at which they can escape.
Input
The first line contains the number of teachers and the number of class periods , separated by a space.
Each of the next lines contains a string of length made of O and X. If the -th character of the -th line is O, the -th teacher patrols at time . If it is X, the -th teacher does not patrol at time .
Output
Print the period of the earliest moment at which the students can escape without being caught. If the students cannot escape without being caught, print ESCAPE FAILED.