import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
static int badukpan[][] = new int [30][30];
static int type;
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int i, j;
for (i = 0; i < 19; i++) {
st = new StringTokenizer(in.readLine());
for (j = 0; j < 19; j++) {
badukpan[i][j] = Integer.parseInt(st.nextToken());
}
}
boolean a, b, c, d;
int flag = 0;
for (i = 0; i < 19; i++) {
for (j = 0; j < 19; j++) {
if (badukpan[i][j] == 1 || badukpan[i][j] == 2) {
a = f1(i,j);
b = f2(i,j);
c = f3(i,j);
d = f4(i,j);
if (a == true) {
bw.write(String.format("%d\n", badukpan[i][j]));
bw.write(String.format("%d %d", i + 1, j + 1));
bw.flush();
flag = 1;
}
else if (b == true) {
bw.write(String.format("%d\n", badukpan[i][j]));
bw.write(String.format("%d %d", i + 1, j + 1));
bw.flush();
flag = 1;
}
else if (c == true) {
bw.write(String.format("%d\n", badukpan[i][j]));
bw.write(String.format("%d %d", i + 1, j + 1));
bw.flush();
flag = 1;
}
else if (d == true) {
bw.write(String.format("%d\n", badukpan[i][j]));
bw.write(String.format("%d %d", i + 1, j + 1));
bw.flush();
flag = 1;
}
}
}
}
if (flag == 0) {
bw.write("0");
bw.flush();
}
}
private static boolean f1(int y, int x) { //----------->
// TODO Auto-generated method stub
if(x-1>=0 && badukpan[y][x-1]==badukpan[y][x]) return false;
for(int i=1;i<5;i++)
{
if(badukpan[y][x+i]!=badukpan[y][x]) return false;
}
if(badukpan[y][x+5]==badukpan[y][x]) return false;
return true;
}
private static boolean f2(int y, int x) {
if (x-1 >= 0 && y-1 >= 0 && badukpan[y - 1][x - 1] == badukpan[y][x]) return false;
for (int i = 1; i < 5; i++) {
if (badukpan[y + i][x + i] != badukpan[y][x]) return false;
}
if (badukpan[y + 5][x + 5] == badukpan[y][x]) return false;
return true;
}
private static boolean f3(int y, int x) {
if (y - 1 >= 0 && badukpan[y - 1][x] == badukpan[y][x]) return false;
for (int i = 1; i < 5; i++) {
if (badukpan[y + i][x] != badukpan[y][x]) return false;
}
if (badukpan[y + 5][x] == badukpan[y][x]) return false;
return true;
}
private static boolean f4(int y, int x) {
if (x - 1 >= 0 && badukpan[y + 1][x - 1] == badukpan[y][x]) return false;
for (int i = 1; i < 5; i++) {
if(y - i<0) return false;
if (badukpan[y - i][x + i] != badukpan[y][x]) return false;
}
if (y - 5 >= 0 && badukpan[y - 5][x + 5] == badukpan[y][x]) return false;
return true;
}
}
http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=1006&sca=2060
'정올문제소스코드' 카테고리의 다른 글
1761 : 숫자 야구 (0) | 2021.10.29 |
---|---|
1031 : 빙고 (0) | 2021.10.29 |
1997 : 떡 먹는 호랑이 (0) | 2021.10.29 |
1311 : 카드게임 (0) | 2021.10.29 |
1671 : 색종이(중) (0) | 2021.10.29 |