C 프로그래밍/BOJ
-
[백준 11562] 백양로 브레이크C 프로그래밍/BOJ 2022. 10. 2. 13:25
++22.11.07 갱신.. 인간은 같은 실수를 반복.... 슬픔.. https://www.acmicpc.net/problem/11562 11562번: 백양로 브레이크 서울 소재 Y모 대학교에서 대규모 공사를 진행하면서, 학교가 마치 미로처럼 변해버리고 말았다. 공사 이전까지는 어떤 건물에서 출발하더라도 다른 모든 건물로 갈 수 있는 길이 있었으나, 공 www.acmicpc.net #include #include #include int N, M; int K; int Adj[250 + 2][250 + 2]; struct _st { int node; int change; }; std::queue Q; int visited[250 + 2][250 + 2];// s -> e로 가는 최소의 cost void in..
-
[백준 2665] 미로만들기C 프로그래밍/BOJ 2022. 10. 1. 22:58
https://www.acmicpc.net/problem/2665 2665번: 미로만들기 첫 줄에는 한 줄에 들어가는 방의 수 n(1 ≤ n ≤ 50)이 주어지고, 다음 n개의 줄의 각 줄마다 0과 1이 이루어진 길이가 n인 수열이 주어진다. 0은 검은 방, 1은 흰 방을 나타낸다. www.acmicpc.net #include #include #include int N; char room[50 + 2][50 + 2]; int chk[50 + 2][50 + 2];// 검은방 -> 흰방 바꾼 개수 struct _st { int x; int y; int flag;// 검은방-> 흰방 몇개 바꾸었는지 }; std::queue Q; void input() { scanf("%d", &N); for (int i = ..
-
[백준 17141] 연구소 3C 프로그래밍/BOJ 2022. 10. 1. 18:36
https://www.acmicpc.net/problem/17142 17142번: 연구소 3 인체에 치명적인 바이러스를 연구하던 연구소에 승원이가 침입했고, 바이러스를 유출하려고 한다. 바이러스는 활성 상태와 비활성 상태가 있다. 가장 처음에 모든 바이러스는 비활성 상태이고 www.acmicpc.net #include #include #include #include int N, M; int choice[10 + 2];// 최대 10개까지 선택 가능 int visited[50 + 2][50 + 2]; int board[50 + 2][50 + 2]; int v_size;// 바이러스를 저장한 벡터의 사이즈 int min_val = 0x7fffffff;// 최소 시간 int cnt_zero;// 빈칸의 개수를..
-
[백준 17070] 파이프 옮기기 1C 프로그래밍/BOJ 2022. 9. 30. 18:48
https://www.acmicpc.net/problem/17070 17070번: 파이프 옮기기 1 유현이가 새 집으로 이사했다. 새 집의 크기는 N×N의 격자판으로 나타낼 수 있고, 1×1크기의 정사각형 칸으로 나누어져 있다. 각각의 칸은 (r, c)로 나타낼 수 있다. 여기서 r은 행의 번호, c는 열의 www.acmicpc.net #include #include int N; int map_pipe[16 + 2][16 + 2]; int visited[16 + 2][16 + 2]; int dir_x[3] = { 0, 1, 1 };// 우0 , 대1 , 하2 int dir_y[3] = { 1, 1, 0 }; struct _st { int x; int y; int dir; }; std::queue Q; v..
-
[백준 11967] 불켜기C 프로그래밍/BOJ 2022. 9. 30. 01:38
https://www.acmicpc.net/problem/11967 11967번: 불켜기 (1, 1)방에 있는 스위치로 (1, 2)방과 (1, 3)방의 불을 켤 수 있다. 그리고 (1, 3)으로 걸어가서 (2, 1)방의 불을 켤 수 있다. (2, 1)방에서는 다시 (2, 2)방의 불을 켤 수 있다. (2, 3)방은 어두워서 갈 수 없으 www.acmicpc.net #include #include #include #include using namespace std; int N, M; struct _st { int x; int y; }; vector ROOM[100 + 2][100 + 2]; queue Q; int visited[100 + 2][100 + 2]; int lights[100 + 2][100 +..
-
[백준 5846] TractorC 프로그래밍/BOJ 2022. 9. 29. 23:46
https://www.acmicpc.net/problem/5846 5846번: Tractor One of Farmer John's fields is particularly hilly, and he wants to purchase a new tractor to drive around on it. The field is described by an N x N grid of non-negative integer elevations (1 N - 1 || ny N - 1) continue;// 영역을 벗어났다면 스루 if (visited[nx][ny]) continue; // 방문했다면 스루 if (abs(field[nx][ny] - field[data.x][data.y]) > D) cont..
-
[백준 5926] Cow LineupC 프로그래밍/BOJ 2022. 9. 29. 22:13
https://www.acmicpc.net/problem/5926 5926번: Cow Lineup Input Details There are 6 cows, at positions 25,26,15,22,20,30, with respective breed IDs 7,1,1,3,1,1. Output Details The range from x=22 up through x=26 (of total size 4) contains each of the distinct breed IDs 1, 3, and 7 represented in FJ's herd. www.acmicpc.net #include #include #include using namespace std; int N; struct _st { int x; in..
-
[백준 3967] 매직 스타C 프로그래밍/BOJ 2022. 9. 29. 20:41
https://www.acmicpc.net/problem/3967 3967번: 매직 스타 매직 스타의 모양이 주어진다. 수가 채워져 있지 않은 곳은 x로, 채워져 있는 곳은 'A'부터 'L'까지 알파벳으로 채워져 있다. i번째 알파벳은 숫자 i를 의미한다. '.'는 매직 스타의 형태를 만들기 www.acmicpc.net #include #include #include using namespace std; int used[12 + 2]; char map_in[5 + 2][9 + 2]; int board[5 + 2][9 + 2];// 계산하기 편하려고 숫자로 바꿔줄 것임 struct _st { int x; int y; }; vector B;// x로 주어진 곳의 좌표 void debug() { for (in..