/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
5\times 5 のマス目があり、いくつかのマスに印が付けられています。
現在のマス目の様子が、o と . からなる長さ 5 の文字列 S_1,S_2,S_3,S_4,S_5 によって与えられます。
上から i 行目、左から j 列目のマスには S_i の j 文字目が o のとき印が付いており、. のとき印が付いていません。
ビンゴを達成するために追加で付ける必要のある印の個数の最小値を求めてください。
ここでビンゴを達成するとは、縦・横・斜めのいずれか一列に並んだ 5 マスで、全てに印が付いているものが存在することをいいます。
制約
- S_1,S_2,S_3,S_4,S_5 は
oと.からなる長さ 5 の文字列
入力
入力は以下の形式で標準入力から与えられる。
S_1 S_2 S_3 S_4 S_5
出力
答えを出力せよ。
入力例 1
.o..o ..oo. .o..o o.o.. o..oo
出力例 1
2
例えば上から 5 行目の左から 2,3 列目の 2 マスに印を付けることでビンゴを達成できます。
入力例 2
o..oo ...o. o.ooo oo.o. .o.oo
出力例 2
0
すでにビンゴを達成している場合、追加で印を付ける必要はないため答えは 0 です。
入力例 3
o..o. .o... ..o.o ..o.. o...o
出力例 3
1
Score : 200 points
Problem Statement
There is a 5\times 5 grid, and some of the cells are marked.
The current state of the grid is given by strings S_1,S_2,S_3,S_4,S_5 of length 5 consisting of o and ..
The cell at the i-th row from the top and the j-th column from the left is marked if the j-th character of S_i is o, and unmarked if it is ..
Find the minimum number of additional marks needed to achieve a bingo.
Here, achieving a bingo means that there exist 5 cells lined up in a single vertical, horizontal, or diagonal line, all of which are marked.
Constraints
- Each of S_1,S_2,S_3,S_4,S_5 is a string of length 5 consisting of
oand..
Input
The input is given from Standard Input in the following format:
S_1 S_2 S_3 S_4 S_5
Output
Print the answer.
Sample Input 1
.o..o ..oo. .o..o o.o.. o..oo
Sample Output 1
2
For example, you can achieve a bingo by marking the 2 cells in the 5-th row from the top and the 2-nd and 3-rd columns from the left.
Sample Input 2
o..oo ...o. o.ooo oo.o. .o.oo
Sample Output 2
0
If a bingo is already achieved, no additional marks are needed, so the answer is 0.
Sample Input 3
o..o. .o... ..o.o ..o.. o...o
Sample Output 3
1