/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("PRX WIN");
return 0;
}
*/
//캔디팡_BFS
#include <stdio.h>
#include <string.h>
int s, r=0, cnt=0, i, j;
int a[9][9]={};
int queue[50][2]={};
int front=-1, back=-1;
int px, py;
int color;
//queue[i][0] : 행
//queue[i][1] : 열
void push(int x, int y)
{
back++;
queue[back][0]=x;
queue[back][1]=y;
a[x][y]=0;
}
void pop()
{
if(back==front){
return ;
}
front++;
px = queue[front][0];
py = queue[front][1];
}
void queue_view()
{
for(int i=front+1;i<=back;i++)
printf("%d %d\n",queue[i][0],queue[i][1]);
printf("\n");
}
void bfs(int x, int y)
{
push(x, y);
while(front!=back){
pop();
//a[px][py]와 연결되어있으면서 방문하지 않은모든 노드 push
if(px-1>=1 && a[px-1][py]==color){
push(px-1, py);
r++;
}
if(py-1>=1 && a[px][py-1]==color){
push(px, py-1);
r++;
}
if(px+1<=7 && a[px+1][py]==color){
push(px+1, py);
r++;
}
if(py+1<=7 && a[px][py+1]==color){
push(px, py+1);
r++;
}
queue_view();
}
printf("bfs end<<\n");
}
int main()
{
for(i=1; i<=7; i++){
for(j=1; j<=7; j++){
scanf("%d", &a[i][j]);
}
}
for(i=1; i<=7; i++){
for(j=1; j<=7; j++){
if(a[i][j]!=0){
printf("bfs start : %d %d >> \n",i, j);
color = a[i][j];
bfs(i, j); // a[i][j]에서 bfs 시작하기
if(r>=3){
cnt++;
}
r=0;
}
}
}
printf("%d", cnt);
return 0;
}
//숫자 등고선
/*
#include <stdio.h>
int main()
{
return 0;
}
*/
//체스 말 이동
/*
#include <stdio.h>
int main()
{
return 0;
}
*/
//토마토_BFS
/*
#include <stdio.h>
int main()
{
return 0;
}
*/



