top of page

소스 코드 제출

공개·회원 81명

20260528

//#include <stdio.h>

//#include <algorithm>

//#include <vector>

//using namespace std;

//

//int cnt = 0;

//int n;

//int ma[30][30] = {0,};

//vector<int>manu;

//void dfs(int x, int y)

//{

// if (x < 1 || x > n || y < 1 || y > n || ma[x][y] != 1)

// {

// return;

// }

//

// manu[cnt]++;

// ma[x][y] = 0;

//

// dfs(x, y + 1);

// dfs(x, y - 1);

// dfs(x + 1, y);

// dfs(x - 1, y);

//}

//

//int main()

//{

// int j, i;

// scanf("%d", &n);

//

// for (i = 1; i <=n; i++)

// {

// for (j = 1; j <=n; j++)

// {

// scanf("%1d", &ma[i][j]);

// }

// }

//// for (i = 1; i <=n; i++)

//// {

//// for (j = 1; j <=n; j++)

//// {

//// printf("%d", ma[i][j]);

//// }

//// printf("\n");

//// }

// manu.push_back(0);

//

// for (i = 1; i <= n; i++)

// {

// for (j = 1; j <= n; j++)

// {

// if (ma[i][j] == 1)

// {

// cnt++;

// manu.push_back(0);

// dfs(i, j);

// }

// else

// {

// continue;

// }

// }

// }

//

// sort(manu.begin(),manu.end());

//

// printf("%d\n", cnt);

// for (i = 1; i <= cnt; i++)

// {

// printf("%d\n", manu[i]);

// }

//

// return 0;

//}


#include <stdio.h>

using namespace std;

int candy[50][50]= {0,};

int cnt=0;

int bef=0;

int c=0;

void dfs(int x,int y)

{


if(x<1 || x>7 || y<1 || y>7 || candy[x][y]!=bef)

{

return;

}

else if(c%3==0)

{

cnt=cnt+1;

c=0;

return;

}

c=c+1;

candy[x][y]=0;

dfs(x,y+1);

dfs(x,y-1);

dfs(x+1,y);

dfs(x-1,y);


}

int main()

{

int i,j,k,n;


for(i=1; i<=7; i++)

{

for(j=1; j<=7; j++)

{

scanf("%d",&candy[i][j]);

}

}


for(i=1; i<=7; i++)

{

for(j=1; j<=7; j++)

{

if(candy[i][j]==0)

{

continue;

}

else

{

bef=candy[i][j];

dfs(i,j);

}

}

}

printf("%d",cnt);

return 0;

}

3회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page