C 프로그래밍/BOJ
-
[백준 6987] 월드컵C 프로그래밍/BOJ 2022. 12. 1. 01:50
https://www.acmicpc.net/problem/6987 6987번: 월드컵 월드컵 조별 최종 예선에서는 6개국으로 구성된 각 조별로 동일한 조에 소속된 국가들과 한 번씩, 각 국가별로 총 5번의 경기를 치른다. 조별리그가 끝난 후, 기자가 보내온 각 나라의 승, 무승부 www.acmicpc.net #include #include int in[4][6][3]; int ans[6][3]; bool Possible[4] = {false, }; int Teams[15][2] = { {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 3}, {2, 4}, {2, 5}, {3, 4}, {3, 5}, {4, 5} }; vo..
-
[백준 3055] 탈출C 프로그래밍/BOJ 2022. 11. 30. 00:23
https://www.acmicpc.net/problem/3055 3055번: 탈출 사악한 암흑의 군주 이민혁은 드디어 마법 구슬을 손에 넣었고, 그 능력을 실험해보기 위해 근처의 티떱숲에 홍수를 일으키려고 한다. 이 숲에는 고슴도치가 한 마리 살고 있다. 고슴도치는 제 www.acmicpc.net #include #include #include int R, C; char in[50 + 2][50 + 2]; int board[50 + 2][50 + 2]; int sx, sy;// 시작위치 struct _st { int flag;// 물: 2, 고슴도치: 3 int x, y; int time; }; std::queue Q; int visited[50 + 2][50 + 2]; void input() { sc..
-
[백준 15683] 감시C 프로그래밍/BOJ 2022. 11. 29. 11:17
https://www.acmicpc.net/problem/15683 15683번: 감시 스타트링크의 사무실은 1×1크기의 정사각형으로 나누어져 있는 N×M 크기의 직사각형으로 나타낼 수 있다. 사무실에는 총 K개의 CCTV가 설치되어져 있는데, CCTV는 5가지 종류가 있다. 각 CCTV가 감 www.acmicpc.net #include #include #include #include int N, M; int board[8 + 2][8 + 2]; int blank; int ans; struct _st { int type; int x, y; }; std::vector V; int choice[8 + 2];// cctv 최대 개수 8개 struct _qt { int x, y; }; std::queue Q; ..
-
[백준 14500] 테트로미노C 프로그래밍/BOJ 2022. 11. 28. 14:23
https://www.acmicpc.net/problem/14500 14500번: 테트로미노 폴리오미노란 크기가 1×1인 정사각형을 여러 개 이어서 붙인 도형이며, 다음과 같은 조건을 만족해야 한다. 정사각형은 서로 겹치면 안 된다. 도형은 모두 연결되어 있어야 한다. 정사각형의 변 www.acmicpc.net #include #include int N, M; int A[500 + 2][500 + 2]; int ans; int tetro_lookup[19][4][2] = { // | {{0, 0}, {0, 1}, {0, 2}, {0, 3}}, // ㅡ {{0, 0}, {1, 0}, {2, 0}, {3, 0}}, // cube {{0, 0}, {0, 1}, {1, 0}, {1, 1}}, // |_ {{0,..
-
[백준 13460] 구슬탈출 2C 프로그래밍/BOJ 2022. 11. 27. 21:13
https://www.acmicpc.net/problem/13460 13460번: 구슬 탈출 2 첫 번째 줄에는 보드의 세로, 가로 크기를 의미하는 두 정수 N, M (3 ≤ N, M ≤ 10)이 주어진다. 다음 N개의 줄에 보드의 모양을 나타내는 길이 M의 문자열이 주어진다. 이 문자열은 '.', '#', 'O', 'R', 'B' www.acmicpc.net #include #include #include int N, M; char board[10 + 2][10 + 2]; int rx, ry; int bx, by; struct _st { int rx, ry; int bx, by; int move; }; std::queue Q; int visited[10 + 2][10 + 2][10 + 2][10 + 2..
-
[백준 20926] 얼음미로C 프로그래밍/BOJ 2022. 11. 27. 17:21
https://www.acmicpc.net/problem/20926 20926번: 얼음 미로 탐험가 테라는 얼음 미로에 갇혔다. 얼음 미로의 바닥은 빙판으로 되어 있어 발을 내디디면 바위에 부딪힐 때까지 미끄러진다. 예를 들어, 위 그림에서 테라가 왼쪽 방향으로 이동한다면 중간에 www.acmicpc.net #include #include #include int R, C; char in[500 + 2][500 + 2]; int board[500 + 2][500 + 2]; int tx, ty; int ex, ey; struct _st { int x, y; int time; }; struct COMP { bool operator()(const _st &a, const _st &b) { return a.tim..
-
[백준 4577] 소코반C 프로그래밍/BOJ 2022. 11. 27. 17:13
https://www.acmicpc.net/problem/4577 4577번: 소코반 소코반은 1982년에 일본에서 만들어진 게임으로, 일본어로 창고지기라는 뜻이다. 이 게임은 캐릭터를 이용해 창고 안에 있는 박스를 모두 목표점으로 옮기는 게임이다. 목표점의 수와 박스의 수 www.acmicpc.net #include #include #include #include int R, C; char board[15 + 2][15 + 2]; char cmd[50 + 2]; int wx, wy; std::queue Q; struct _st { int x, y; }; std::vector V; void input() { // init memset(board, '0', sizeof(board)); memset(cmd,..
-
[백준 2307] 도로검문C 프로그래밍/BOJ 2022. 11. 24. 15:24
https://www.acmicpc.net/problem/2307 2307번: 도로검문 그림 1은 어떤 도시의 주요 지점과 그 지점들 간의 이동시간을 나타낸 그래프이다. 그래프의 노드는 주요 지점을 나타내고 두 지점을 연결한 도로(에지)에 표시된 수는 그 도로로 이동할 때 걸 www.acmicpc.net #include #include #include int N, M; struct _st { int n; int t; }; std::list L[1000 + 2]; struct COMP { bool operator()(const _st &a, const _st &b) { return a.t > b.t; } }; std::priority_queue PQ; int visited[1000 + 2]; int rou..