본문 바로가기
SWE/코테

백준_1012_유기농 배추

by S나라라2 2018. 7. 19.
반응형


맞은 정답


	
// c++ 쓰기

#include
#include
using namespace std;

int testcase;
int m, n, k; // 가로길이, 세로길이, 배추 개수

int arr[51][51] = { 0, };
int cnt = 0; // 배추 갯수
int result;

int x_offset[4] = { 0,0,-1,1 }; // 상 하 좌 우
int y_offset[4] = { 1,-1,0,0 };

void func(int x, int y);

int main(void) {

	cin >> testcase;
	for (int i = 0; i < testcase; i++) {
		cin >> m >> n >> k;

		for (int j = 0; j < k; j++) {
			int x, y;
			cin >> x >> y;
			arr[x][y] = 1;
		}

		int x = 0, y = 0;
		while (cnt= m || _y<0 || _y >= n
			|| arr[_x][_y] != 1) {
			continue;
		}
		func(_x, _y);
	}
}	


반응형