본문 바로가기

알고리즘

(28)
백준 11403 경로 찾기 #include #include #include using namespace std; int N; int Map[100][100]; int result[100][100]; bool visit[100]; queue q; void Calc() { for (int i = 0; i < N; i++) { for (int q = 0; q < N; q++) { visit[q] = 0; } for (int j = 0; j < N; j++) { visit[i] = true; if (Map[i][j] == 1) { q.push(j); result[i][j] = 1; } } while (!q.empty()) { int current_po = q.front(); q.pop(); for (int k = 0; k < N; k++..
백준 1012번 유기농배추. #include #include #include using namespace std; typedef struct { int position_x; int position_y; }earth_bug; int test_case; int N, M, K; bool visit[51][51]; int x, y; int Map[51][51]; int result; int dirx[4] = { 0,0,-1,1 }; int diry[4] = { 1,-1,0,0 }; queue q; void Input() { scanf("%d", &test_case); for (int i = 0; i < test_case; i++) { for (int c = 0; c < 51; c++) { for (int y = 0; y < 51; y++)..
백준 2667 단지 번호 #include #include #include using namespace std; typedef struct { int position_x; int position_y; }apartment; int Map[25][25]; bool visit[25][25]; int N; queue q; priority_queue pq; int dirx[4] = {0,0,1,-1}; int diry[4] = {-1,1,0,0}; void Input() { scanf("%d", &N); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { scanf("%1d", &Map[i][j]); } } } void Calc() { for (int i = 0; i < N; i++)..
백준 7576 토마토 그냥 눈대중으로 풀었다. 첫번째로 푼것 : #include #include #include #include #include using namespace std; typedef struct { int position; int time; }tomato; int M, N; int Map[1000][1000]; queue q; int min_count; int dirx[4] = { 0,0,1,-1 }; int diry[4] = { -1,1,0,0 }; clock_t start, endi; void Input() { scanf("%d %d", &M, &N); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { scanf("%d", &Map[i][j]); if..