BINGO!
시간 제한5초메모리 제한2048 MB
이벤트 이름이 적힌 n x n 빙고 카드와 강의 중 일어나는 m개의 이벤트가 주어질 때, 처음으로 가로, 세로, 대각선 한 줄이 완성되는 시점을 구한다.
문제
A common activity for students during a lecture is playing BINGO. However, they don't play the regular boring game with the numbered balls. Instead, their BINGO sheets contain in every square an event that might (or might not) happen during a lecture, and once the event happens, this square can be crossed off.
Since you'd also like to pay attention during the lecture while playing this game, you decide to build a program that automatically plays BINGO for you. Given a BINGO sheet with a grid of squares, and a list of events that happen during the lecture, how many events will pass before you can shout "BINGO!"?
Note that you may shout "BINGO!" whenever you crossed off all squares in any row, column, or diagonal of the grid. The middle square in your grid can always be crossed off for free.
입력
One line containing two integers: one odd integer , with , and one integer , with . lines, each containing space-separated events. Event names consist of only alphanumeric characters, and every event only happens at most once. lines, with on every line an event that happens during the lecture.
출력
One integer, indicating after how many events you can shout "BINGO!". If you cannot shout "BINGO!" during this lecture, output a sad smiley face: :-(