'BFS' 태그의 글 목록
본문 바로가기
728x90
반응형

BFS40

2022-04-28-19238-스타트택시 01.택시 승하차 01.1 손님 탐색 int visit[NS][NS] = { 0, }; queuet; Taxi.feul = F; t.push(Taxi); int minY, minX, minCnt; minY = minX = minCnt = 0x7fffffff; int fuel, used; visit[Taxi.y][Taxi.x] = 0; int number = 0; while (!t.empty()) { Pos c = t.front(); t.pop(); //if (c.feul == 0 && startBoard[c.y][c.x].isStart != 1) return -1; if (startBoard[c.y][c.x].isStart == 1) { // 최소값 뽑는 부분 if (minCnt >= c.cnt) { m.. 2022. 4. 28.
22-04-24-16236-아기상어 01.거리최소값구하기 조건은 최소의 거리이고 최소가 많은 경우 y가 최소이고 y가최소인게 많으면 x가 최소인 것 if (board[c.y][c.x]!=0&&board[c.y][c.x]= c.eat) {//최소값 minCnt = c.eat; if (minY > c.y || (minY == c.y&&minX > c.x)) { minY = c.y; minX = c.x; } } 02.BFS 모든 경우를 확인 대신 최소를 저장하면서 확인 진행 최소의 모든 경우를 보는 이유는 최소가 여러개이기 때문 while (!s.empty()) { Data c = s.front(); s.pop(); if (board[c.y][c.x]!=0&&board[c.y][c.x]= c.eat) {//최소값 minCnt = c.eat; i.. 2022. 4. 21.
2021.10.03_19238-스타트택시 소스코드 #include #include #include #include #include using namespace std; #define SIZE 21 struct Data { int y, x, cnt, fuel, num; }; int N, M, Fuel, answer; int r = 0; int startBoard[SIZE][SIZE];//승객 위치 int endBoard[402][SIZE][SIZE];// 승객 도착위치 int dy[] = { 0,1,0,-1 }; int dx[] = { 1,0,-1,0 }; queuetaxi; int visit[SIZE][SIZE];//방문체크 void init();//초기화 및 초기 입력 void startTaxi();// 택시 주행 void searchPeop.. 2021. 10. 3.
2021.09.23_17141-연구소2_17142-연구소3 소스코드 | 17141 #include #include #include #include #include #include using namespace std; #define SIZE 51 int N, M;// 배열크기, 바이러스 선택 int answer;//결과값 int lab[SIZE][SIZE];//바이러스 상태 표시 int dy[] = { 0,1,0,-1 }; int dx[] = { 1,0,-1,0 }; struct Data { int y, x, cnt; }; vectorv; void init();//초기화 void dfs(Data c); bool safeZone(int y, int x);//범위 체크 int main(void) { int testCase = 1; for (int tc = 1; tc 2021. 9. 23.
728x90
반응형